You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by em...@apache.org on 2021/10/29 14:21:58 UTC
[incubator-age-viewer] 05/08: Update Connection error message
improvement.
This is an automated email from the ASF dual-hosted git repository.
emotionbug pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-age-viewer.git
commit 9bbd3d15769eb4f3cb9b2e0a5e9229047a49211a
Author: shinhanbyeol <si...@gmail.com>
AuthorDate: Mon Oct 25 16:27:30 2021 +0900
Update Connection error message improvement.
1. Add severity and error code to the error alert message.
---
backend/src/app.js | 8 +++++++-
frontend/src/features/database/DatabaseSlice.js | 4 +++-
frontend/src/features/database/MetadataSlice.js | 2 ++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/backend/src/app.js b/backend/src/app.js
index e7e5f4c..9c66fad 100644
--- a/backend/src/app.js
+++ b/backend/src/app.js
@@ -66,7 +66,13 @@ app.use('/api/v1/feature', FeatureRouter);
app.use(function (err, req, res, next) {
// TODO: logger
console.error(err);
- res.status(err.status || 500).json({message: err.message});
+ res.status(err.status || 500).json(
+ {
+ severity: err.severity || '',
+ message: err.message || '',
+ code: err.code || ''
+ }
+ );
});
process.on('uncaughtException', function (exception) {
diff --git a/frontend/src/features/database/DatabaseSlice.js b/frontend/src/features/database/DatabaseSlice.js
index 5226fec..bcfc24a 100644
--- a/frontend/src/features/database/DatabaseSlice.js
+++ b/frontend/src/features/database/DatabaseSlice.js
@@ -35,7 +35,7 @@ export const connectToAgensGraph = createAsyncThunk(
const errorJson = await error.json();
const errorDetail = {
name: 'Failed to Retrieve Connection Information',
- message: errorJson.message,
+ message: `[${errorJson.severity}]:(${errorJson.code}) ${errorJson.message} `,
statusText: error.statusText,
};
throw errorDetail;
@@ -58,8 +58,10 @@ export const getConnectionStatus = createAsyncThunk(
if (response.ok) { return await response.json(); }
throw response;
} catch (error) {
+ const errorJson = await error.json();
const errorDetail = {
name: 'Failed to Retrieve Connection Information',
+ message: `[${errorJson.severity}]:(${errorJson.code}) ${errorJson.message} `,
statusText: error.statusText,
};
throw errorDetail;
diff --git a/frontend/src/features/database/MetadataSlice.js b/frontend/src/features/database/MetadataSlice.js
index d7949fa..be1467c 100644
--- a/frontend/src/features/database/MetadataSlice.js
+++ b/frontend/src/features/database/MetadataSlice.js
@@ -40,6 +40,7 @@ export const getMetaData = createAsyncThunk(
} catch (error) {
const errorDetail = {
name: 'Database Connection Failed',
+ message: `[${error.severity}]:(${error.code}) ${error.message} `,
statusText: error.statusText,
};
throw errorDetail;
@@ -59,6 +60,7 @@ export const getMetaChartData = createAsyncThunk(
} catch (error) {
const errorDetail = {
name: 'Database Connection Failed',
+ message: `[${error.severity}]:(${error.code}) ${error.message} `,
statusText: error.statusText,
};
throw errorDetail;