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

feat: axios error handler, extract status from JS error (VF-000) #91

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

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.

@@ -15,6 +15,7 @@
"@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
1 participant