fix: return correct error

This commit is contained in:
Paul Makles
2022-05-17 21:10:47 +01:00
parent 3cbf6e1d1f
commit acc446dc60
2 changed files with 6 additions and 2 deletions

2
external/lang vendored

View File

@@ -8,6 +8,10 @@ import { Children } from "../../types/Preact";
export function takeError(error: any): string { export function takeError(error: any): string {
if (error.response) { if (error.response) {
const status = error.response.status; const status = error.response.status;
if (error.response.type) {
return error.response.type;
}
switch (status) { switch (status) {
case 429: case 429:
return "TooManyRequests"; return "TooManyRequests";
@@ -15,7 +19,7 @@ export function takeError(error: any): string {
case 403: case 403:
return "Unauthorized"; return "Unauthorized";
default: default:
return error.response.type ?? "UnknownError"; return "UnknownError";
} }
} else if (error.request) { } else if (error.request) {
return "NetworkError"; return "NetworkError";