From 81d3555000547612aae626e43ca616088ea33279 Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 5 Sep 2023 13:54:27 +0300 Subject: [PATCH 1/3] Add logging che-server exception messages Signed-off-by: Igor --- .../dashboard-frontend/src/store/SanityCheck/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/dashboard-frontend/src/store/SanityCheck/index.ts b/packages/dashboard-frontend/src/store/SanityCheck/index.ts index 9d0ee5a64..d78258581 100644 --- a/packages/dashboard-frontend/src/store/SanityCheck/index.ts +++ b/packages/dashboard-frontend/src/store/SanityCheck/index.ts @@ -107,7 +107,7 @@ export const actionCreators: ActionCreators = { delay(1000); } } - } catch (e) { + } catch (e: any) { let errorMessage = 'Backend is not available. Try to refresh the page or re-login to the Dashboard.'; if (isUnauthorized(e) || isForbidden(e)) { @@ -118,6 +118,12 @@ export const actionCreators: ActionCreators = { type: Type.RECEIVED_BACKEND_CHECK_ERROR, error: errorMessage, }); + if (e.message) { + console.error(e.message); + } + if (e.response && e.response.data && e.response.data.trace) { + console.error(e.response.data.trace.join('\n')); + } throw new Error(errorMessage); } }, From b21633387aeb6c8204d2e5e8510dd8bedda618a7 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 6 Sep 2023 11:22:00 +0300 Subject: [PATCH 2/3] fixup! Add logging che-server exception messages --- packages/dashboard-frontend/src/store/SanityCheck/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/dashboard-frontend/src/store/SanityCheck/index.ts b/packages/dashboard-frontend/src/store/SanityCheck/index.ts index d78258581..c2deb0f5b 100644 --- a/packages/dashboard-frontend/src/store/SanityCheck/index.ts +++ b/packages/dashboard-frontend/src/store/SanityCheck/index.ts @@ -12,6 +12,7 @@ import { Action, Reducer } from 'redux'; import { AppThunk } from '..'; +import { helpers } from '@eclipse-che/common'; import { container } from '../../inversify.config'; import { getDefer } from '../../services/helpers/deferred'; import { delay } from '../../services/helpers/delay'; @@ -118,9 +119,7 @@ export const actionCreators: ActionCreators = { type: Type.RECEIVED_BACKEND_CHECK_ERROR, error: errorMessage, }); - if (e.message) { - console.error(e.message); - } + console.error(helpers.errors.getMessage(e)); if (e.response && e.response.data && e.response.data.trace) { console.error(e.response.data.trace.join('\n')); } From 4211ca052ddbe250b10d4142de18ea1b3e97d9b4 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 6 Sep 2023 14:52:13 +0300 Subject: [PATCH 3/3] fixup! Add logging che-server exception messages --- .../dashboard-frontend/src/store/SanityCheck/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/dashboard-frontend/src/store/SanityCheck/index.ts b/packages/dashboard-frontend/src/store/SanityCheck/index.ts index c2deb0f5b..b43807b09 100644 --- a/packages/dashboard-frontend/src/store/SanityCheck/index.ts +++ b/packages/dashboard-frontend/src/store/SanityCheck/index.ts @@ -108,7 +108,7 @@ export const actionCreators: ActionCreators = { delay(1000); } } - } catch (e: any) { + } catch (e) { let errorMessage = 'Backend is not available. Try to refresh the page or re-login to the Dashboard.'; if (isUnauthorized(e) || isForbidden(e)) { @@ -120,7 +120,11 @@ export const actionCreators: ActionCreators = { error: errorMessage, }); console.error(helpers.errors.getMessage(e)); - if (e.response && e.response.data && e.response.data.trace) { + if ( + helpers.errors.includesAxiosResponse(e) && + e.response.data.trace && + Array.isArray(e.response.data.trace) + ) { console.error(e.response.data.trace.join('\n')); } throw new Error(errorMessage);