-
Notifications
You must be signed in to change notification settings - Fork 9
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 axios error handler that handles drf messages #324
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,23 @@ | |||
import { isAxiosError, AxiosError } from 'axios' | |||
|
|||
export function handleDRFAPIErrorsOrReThrow(error: AxiosError | Error): string[]{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say error is unknown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AxiosError
type is inferred by the isAxiosError
assert function on it's own, no need to declare it at all
const e: AxiosError = error | ||
|
||
const { data } = (e as AxiosError)?.response ?? null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to cast here. In neither of the two lines
} | ||
return [] | ||
} | ||
throw error as Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether the cast does anything at all here 🤔
What this does
Add a description of what feature/page this PR intends to add or change.
Checklist
How to test
Add user steps to achieve desired functionality for this feature.