Skip to content

Conversation

@trs
Copy link
Contributor

@trs trs commented Jun 29, 2022

Fixes or implements VF-000

Brief description. What is this change?

Adds an error format handler for axios errors.

Attempts to extract a status or statusCode from a JS error for formatting.

"@types/http-errors": "^1.8.2",
"@voiceflow/logger": "1.6.1",
"@voiceflow/verror": "^1.1.0",
"axios": "0.27.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if we should just declare the type instead of including the entirety of axios.

export const formatAxiosError: ExceptionFormatter<AxiosError> = (err) => {
return {
statusCode: err.response?.status,
name: 'AxiosError',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we're returning this to the client, we probably don't want to leak that errors are axios, gaxios, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants