mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
fix: return correct error
This commit is contained in:
2
external/lang
vendored
2
external/lang
vendored
Submodule external/lang updated: fd152393e4...10c4f3be26
@@ -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";
|
||||||
|
|||||||
Reference in New Issue
Block a user