Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a handler for AxiosError errors #189

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/app-nordigen/app-nordigen.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact! This doesn’t actually narrow the error type away from any. Maybe microsoft/TypeScript#53681 will fix that?

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',
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/189.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [j-f1]
---

More clearly report the problem with Nordigen requests that fail with an unexpected status code