From 3d4316cd44591a6418a84b12a37f6a25fb86709b Mon Sep 17 00:00:00 2001 From: natsoni Date: Thu, 4 Jul 2024 19:38:27 +0900 Subject: [PATCH] Add more context to error messages --- frontend/src/app/components/block/block.component.html | 2 +- frontend/src/app/components/pool/pool.component.html | 9 ++++++++- frontend/src/app/components/pool/pool.component.ts | 6 ++++++ .../app/shared/pipes/http-error-pipe/http-error.pipe.ts | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 6c8693d22..79151ecc3 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -364,7 +364,7 @@ - Error loading data. + Error loading block data. diff --git a/frontend/src/app/components/pool/pool.component.html b/frontend/src/app/components/pool/pool.component.html index bd4f3bbee..b74ecdf81 100644 --- a/frontend/src/app/components/pool/pool.component.html +++ b/frontend/src/app/components/pool/pool.component.html @@ -1,6 +1,6 @@ -
+
@@ -459,4 +459,11 @@ + + + +
+ + Error loading pool data. +
\ No newline at end of file diff --git a/frontend/src/app/components/pool/pool.component.ts b/frontend/src/app/components/pool/pool.component.ts index 2648bc4ca..6564a5dd9 100644 --- a/frontend/src/app/components/pool/pool.component.ts +++ b/frontend/src/app/components/pool/pool.component.ts @@ -9,6 +9,7 @@ import { StateService } from '../../services/state.service'; import { selectPowerOfTen } from '../../bitcoin.utils'; import { formatNumber } from '@angular/common'; import { SeoService } from '../../services/seo.service'; +import { HttpErrorResponse } from '@angular/common/http'; interface AccelerationTotal { cost: number, @@ -33,6 +34,7 @@ export class PoolComponent implements OnInit { blocks$: Observable; oobFees$: Observable; isLoading = true; + error: HttpErrorResponse | null = null; chartOptions: EChartsOption = {}; chartInitOptions = { @@ -105,6 +107,10 @@ export class PoolComponent implements OnInit { } return this.apiService.getPoolBlocks$(this.slug, this.blocks[this.blocks.length - 1]?.height); }), + catchError((err) => { + this.error = err; + return of([]); + }), tap((newBlocks) => { this.blocks = this.blocks.concat(newBlocks); }), diff --git a/frontend/src/app/shared/pipes/http-error-pipe/http-error.pipe.ts b/frontend/src/app/shared/pipes/http-error-pipe/http-error.pipe.ts index 3cbb16df6..51e9c4c0b 100644 --- a/frontend/src/app/shared/pipes/http-error-pipe/http-error.pipe.ts +++ b/frontend/src/app/shared/pipes/http-error-pipe/http-error.pipe.ts @@ -4,6 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'httpErrorMsg' }) export class HttpErrorPipe implements PipeTransform { transform(e: HttpErrorResponse | null): string { - return e ? `${e.status}: ${e.statusText}` : ''; + return e ? `${e.status} ${e.statusText}: ${e.error}` : ''; } }