Add a handler for AxiosError errors (#189)

This commit is contained in:
Jed Fox
2023-04-17 15:54:36 -04:00
committed by GitHub
parent 104c9803f7
commit 652d75a939
2 changed files with 20 additions and 2 deletions

View File

@@ -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',

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [j-f1]
---
More clearly report the problem with Nordigen requests that fail with an unexpected status code