Skip to content

Commit

Permalink
fix: formatting exception message so it could be passed down properly
Browse files Browse the repository at this point in the history
  • Loading branch information
levyitay committed Nov 23, 2022
1 parent 6cc2330 commit 7f70af0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ export async function executeRequest(options: AxiosRequestConfig): Promise<Respo

} catch (ex: any) {
if (process.env.DEBUG == 'true') {
console.error(`Error executing request ${JSON.stringify(ex.response.data)}
status code: ${ex.response.statusCode} `);
console.error(`Error executing request ${JSON.stringify(ex.response?.data || ex.message)}
status code: ${ex.response?.status} `);
}
if (ex.response) {
resObj.msg = ex.response.data;
if (ex.response?.data) {
resObj.msg = (typeof ex.response.data == 'object') ? JSON.stringify(ex.response.data) : ex.response.data;
resObj.errorCode = ex.response.status;
} else {
resObj.msg = ex.message;
resObj.errorCode = 500;

}
}
return resObj;
Expand Down

0 comments on commit 7f70af0

Please sign in to comment.