From a3ba2d8041382b37fdd7099af4063d6143f6a7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Fri, 6 Jul 2018 21:30:31 +0200 Subject: [PATCH] fix(ui): more readable fetch errors --- ui/src/Components/NavBar/FilterInput/index.js | 2 +- ui/src/Stores/AlertStore.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/src/Components/NavBar/FilterInput/index.js b/ui/src/Components/NavBar/FilterInput/index.js index d1bc73374..30b636083 100644 --- a/ui/src/Components/NavBar/FilterInput/index.js +++ b/ui/src/Components/NavBar/FilterInput/index.js @@ -80,7 +80,7 @@ const FilterInput = observer( .then(result => { this.inputStore.suggestions = result; }) - .catch(err => console.error(err.toString())); + .catch(err => console.error(err.message)); } }), 300 diff --git a/ui/src/Stores/AlertStore.js b/ui/src/Stores/AlertStore.js index adb644438..be7574a52 100644 --- a/ui/src/Stores/AlertStore.js +++ b/ui/src/Stores/AlertStore.js @@ -170,7 +170,11 @@ class AlertStore { .then(result => { this.parseAPIResponse(result); }) - .catch(err => this.handleFetchError(err.toString())); + .catch(err => + this.handleFetchError( + `Request for ${alertsURI} failed with "${err.message}"` + ) + ); }, 500) ); @@ -188,7 +192,7 @@ class AlertStore { const responseFilters = new Set(result.filters.map(m => m.text).sort()); if (JSON.stringify(queryFilters) !== JSON.stringify(responseFilters)) { console.info( - `Got response with filters=${responseFilters} while expecting results for ${queryFilters}, ignoring!` + `Got response with filters=${responseFilters} while expecting results for ${queryFilters}, ignoring` ); return; } @@ -213,7 +217,7 @@ class AlertStore { console.warn( `Got response with filter ${ filter.text - } which isn't one of applied filters!` + } which isn't one of applied filters, ignoring` ); return; } @@ -245,7 +249,6 @@ class AlertStore { }); handleFetchError = action(err => { - console.error(`fetch() failed: ${err}`); this.status.setFailure(err); // reset alert counter since we won't be rendering any alerts