Add more context to error messages

This commit is contained in:
natsoni 2024-07-04 19:38:27 +09:00
parent 2b96c99fb3
commit 3d4316cd44
No known key found for this signature in database
GPG Key ID: C65917583181743B
4 changed files with 16 additions and 3 deletions

View File

@ -364,7 +364,7 @@
</ng-template> </ng-template>
<ng-template [ngIf]="error"> <ng-template [ngIf]="error">
<app-http-error [error]="error"> <app-http-error [error]="error">
<span i18n="error.general-loading-data">Error loading data.</span> <span i18n="block.error.loading-block-data">Error loading block data.</span>
</app-http-error> </app-http-error>
</ng-template> </ng-template>

View File

@ -1,6 +1,6 @@
<app-indexing-progress></app-indexing-progress> <app-indexing-progress></app-indexing-progress>
<div class="container-xl"> <div class="container-xl" *ngIf="!error; else errorTemplate">
<!-- Pool overview --> <!-- Pool overview -->
<div *ngIf="poolStats$ | async as poolStats; else loadingMain"> <div *ngIf="poolStats$ | async as poolStats; else loadingMain">
@ -459,4 +459,11 @@
<ng-template #emptyTd> <ng-template #emptyTd>
<td class="text-center"></td> <td class="text-center"></td>
</ng-template>
<ng-template #errorTemplate>
<br>
<app-http-error [error]="error">
<span i18n="pool.error.loading-pool-data">Error loading pool data.</span>
</app-http-error>
</ng-template> </ng-template>

View File

@ -9,6 +9,7 @@ import { StateService } from '../../services/state.service';
import { selectPowerOfTen } from '../../bitcoin.utils'; import { selectPowerOfTen } from '../../bitcoin.utils';
import { formatNumber } from '@angular/common'; import { formatNumber } from '@angular/common';
import { SeoService } from '../../services/seo.service'; import { SeoService } from '../../services/seo.service';
import { HttpErrorResponse } from '@angular/common/http';
interface AccelerationTotal { interface AccelerationTotal {
cost: number, cost: number,
@ -33,6 +34,7 @@ export class PoolComponent implements OnInit {
blocks$: Observable<BlockExtended[]>; blocks$: Observable<BlockExtended[]>;
oobFees$: Observable<AccelerationTotal[]>; oobFees$: Observable<AccelerationTotal[]>;
isLoading = true; isLoading = true;
error: HttpErrorResponse | null = null;
chartOptions: EChartsOption = {}; chartOptions: EChartsOption = {};
chartInitOptions = { chartInitOptions = {
@ -105,6 +107,10 @@ export class PoolComponent implements OnInit {
} }
return this.apiService.getPoolBlocks$(this.slug, this.blocks[this.blocks.length - 1]?.height); return this.apiService.getPoolBlocks$(this.slug, this.blocks[this.blocks.length - 1]?.height);
}), }),
catchError((err) => {
this.error = err;
return of([]);
}),
tap((newBlocks) => { tap((newBlocks) => {
this.blocks = this.blocks.concat(newBlocks); this.blocks = this.blocks.concat(newBlocks);
}), }),

View File

@ -4,6 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'httpErrorMsg' }) @Pipe({ name: 'httpErrorMsg' })
export class HttpErrorPipe implements PipeTransform { export class HttpErrorPipe implements PipeTransform {
transform(e: HttpErrorResponse | null): string { transform(e: HttpErrorResponse | null): string {
return e ? `${e.status}: ${e.statusText}` : ''; return e ? `${e.status} ${e.statusText}: ${e.error}` : '';
} }
} }