Skip to content

fix: Check if an API error has data before checking the message #3427

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

Merged
merged 1 commit into from
Aug 9, 2022
Merged
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
fix: Check if an API error has data before checking the message
This was causing the app to crash with an error. I found this manually
by looking through the obfuscated sources in DevTools. It's a
data-point for #3425 though!
  • Loading branch information
kylecarbs committed Aug 9, 2022
commit 22477dbb6a8a76bae60eb0e83d64c4fc761d93fb
3 changes: 3 additions & 0 deletions site/src/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export type ApiError = AxiosError<ApiErrorResponse> & { response: AxiosResponse<
export const isApiError = (err: any): err is ApiError => {
if (axios.isAxiosError(err)) {
const response = err.response?.data
if (!response) {
return false
}

return (
typeof response.message === "string" &&
Expand Down