From 652d75a939eda0d60f79d6efc50a866aafbffdeb Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 17 Apr 2023 15:54:36 -0400 Subject: [PATCH] Add a handler for AxiosError errors (#189) --- src/app-nordigen/app-nordigen.js | 16 ++++++++++++++-- upcoming-release-notes/189.md | 6 ++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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..670f24c2e 100644 --- a/src/app-nordigen/app-nordigen.js +++ b/src/app-nordigen/app-nordigen.js @@ -1,5 +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 { @@ -193,14 +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( + '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', 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