From 2931a4ce1b7ae3390e6bb2086d3266fac473d925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Wed, 27 Nov 2024 18:25:56 +0000 Subject: [PATCH] simplify APIError --- ui/src/lib/api_error.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/src/lib/api_error.ts b/ui/src/lib/api_error.ts index 46deaad..d9d7d4d 100644 --- a/ui/src/lib/api_error.ts +++ b/ui/src/lib/api_error.ts @@ -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":