simplify APIError

This commit is contained in:
Jörn-Michael Miehe 2024-11-27 18:25:56 +00:00
parent 9b494136ee
commit 2931a4ce1b

View file

@ -2,12 +2,10 @@ import { AxiosError } from "axios";
import { toast } from "bulma-toast";
export class APIError extends Error {
reason: unknown;
axios_error: AxiosError | null = null;
axios_error?: AxiosError;
constructor(reason: unknown, endpoint: string) {
super(endpoint); // sets this.message to the endpoint
this.reason = reason;
Object.setPrototypeOf(this, APIError.prototype);
if (reason instanceof AxiosError) {
@ -21,7 +19,7 @@ export class APIError extends Error {
let code = "U";
const result = () => `${msg} (Fehlercode: ${code}/${this.message})`;
if (this.axios_error === null) return result();
if (this.axios_error === undefined) return result();
switch (this.axios_error.code) {
case "ECONNABORTED":