mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-23 05:03:02 +00:00
simplify APIError
This commit is contained in:
parent
9b494136ee
commit
2931a4ce1b
1 changed files with 2 additions and 4 deletions
|
@ -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":
|
||||
|
|
Loading…
Reference in a new issue