Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Changed format of error body
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcui1225 committed Dec 2, 2020
1 parent 7f15f67 commit 5dd385b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion workbench/public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ export class Main extends React.Component<MainProps, MainState> {
};
}

formatQueryErrorBody(data: any) {
let prettyErrorMessage = "";
prettyErrorMessage += 'reason: ' + data.errorReason + '\n';
prettyErrorMessage += 'details: ' + data.errorDetails + '\n';
prettyErrorMessage += 'type: ' + data.errorType + '\n';
prettyErrorMessage += 'status: ' + data.status;
return prettyErrorMessage;
}

processQueryResponse(response: IHttpResponse<ResponseData>): ResponseDetail<string> {
if (!response) {
return {
Expand All @@ -261,7 +270,7 @@ export class Main extends React.Component<MainProps, MainState> {
return {
fulfilled: false,
errorMessage: response.data.resp,
data: response.data.body,
data: this.formatQueryErrorBody(response.data),
};
}

Expand Down
6 changes: 5 additions & 1 deletion workbench/server/services/QueryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ export default class QueryService {
};
} catch (err) {
console.log(err);
const errorObj = JSON.parse(err.body);
return {
data: {
ok: false,
resp: err.message,
body: err.body,
errorReason: errorObj.error.reason,
errorDetails: errorObj.error.details,
errorType: errorObj.error.type,
status: errorObj.status
},
};
}
Expand Down

0 comments on commit 5dd385b

Please sign in to comment.