MCPcopy Create free account
hub / github.com/aptabase/aptabase / handleError

Function handleError

src/webapp/fns/api.ts:3–16  ·  view source on GitHub ↗
(status: number, response: Response)

Source from the content-addressed store, hash-verified

1import { toast } from "sonner";
2
3async function handleError(status: number, response: Response): Promise<void> {
4 if (status >= 500) {
5 // TODO: show error toast
6 } else if (status === 401) {
7 // TODO: show error toast
8 } else if (status === 403) {
9 // TODO: show error toast
10 } else if (status === 400) {
11 const errors = (await response.json()) as ValidationError;
12 const message = Object.values(errors.errors).flat().join("\n");
13 toast.error(message);
14 throw new Error(message);
15 }
16}
17
18const commonHeaders: RequestInit = {
19 credentials: "include",

Callers 5

getFunction · 0.70
postFunction · 0.70
putFunction · 0.70
_deleteFunction · 0.70
getEmptyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected