From 88f6986f153e5ea0ad33c28a20fc1039c8605d17 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 16 Apr 2023 15:08:47 -0400 Subject: [PATCH 1/2] Add a handler for AxiosError errors --- src/app-nordigen/app-nordigen.js | 11 +++++++++++ upcoming-release-notes/189.md | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 upcoming-release-notes/189.md diff --git a/src/app-nordigen/app-nordigen.js b/src/app-nordigen/app-nordigen.js index 7d06fe48e..9d63a64e1 100644 --- a/src/app-nordigen/app-nordigen.js +++ b/src/app-nordigen/app-nordigen.js @@ -1,3 +1,4 @@ +import { isAxiosError } from 'axios'; import express from 'express'; import path from 'path'; @@ -199,6 +200,16 @@ app.post( error_code: 'NORDIGEN_ERROR', }); break; + case isAxiosError(error): + console.log({ + message: 'Something went wrong', + error: error.response.data, + }); + sendErrorResponse({ + error_type: 'SYNC_ERROR', + error_code: 'NORDIGEN_ERROR', + }); + break; default: console.log({ message: 'Something went wrong', error }); sendErrorResponse({ diff --git a/upcoming-release-notes/189.md b/upcoming-release-notes/189.md new file mode 100644 index 000000000..dcbc7b0b3 --- /dev/null +++ b/upcoming-release-notes/189.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [j-f1] +--- + +More clearly report the problem with Nordigen requests that fail with an unexpected status code From fe8cd1b84bc6ecc4ac92a302ccdc882a344769cf Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 16 Apr 2023 17:10:46 -0400 Subject: [PATCH 2/2] Use inspect() with infinite depth to print errors --- src/app-nordigen/app-nordigen.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app-nordigen/app-nordigen.js b/src/app-nordigen/app-nordigen.js index 9d63a64e1..670f24c2e 100644 --- a/src/app-nordigen/app-nordigen.js +++ b/src/app-nordigen/app-nordigen.js @@ -1,6 +1,7 @@ import { isAxiosError } from 'axios'; import express from 'express'; import path from 'path'; +import { inspect } from 'util'; import { nordigenService } from './services/nordigen-service.js'; import { @@ -194,24 +195,24 @@ app.post( }); break; case error instanceof GenericNordigenError: - console.log({ message: 'Something went wrong', error }); + console.log('Something went wrong', inspect(error, { depth: null })); sendErrorResponse({ error_type: 'SYNC_ERROR', error_code: 'NORDIGEN_ERROR', }); break; case isAxiosError(error): - console.log({ - message: 'Something went wrong', - error: error.response.data, - }); + console.log( + 'Something went wrong', + inspect(error.response.data, { depth: null }), + ); sendErrorResponse({ error_type: 'SYNC_ERROR', error_code: 'NORDIGEN_ERROR', }); break; default: - console.log({ message: 'Something went wrong', error }); + console.log('Something went wrong', inspect(error, { depth: null })); sendErrorResponse({ error_type: 'UNKNOWN', error_code: 'UNKNOWN',