generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
33 deletions.
There are no files selected for viewing
27 changes: 25 additions & 2 deletions
27
wls-gui-wahllokalsystem/src/api/ApiError.ts → wls-gui-wahllokalsystem/src/api/WLSError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
import { STATUS_INDICATORS } from "@/constants"; | ||
|
||
export class ApiError extends Error { | ||
// todo: umbenennen in WLSError? | ||
export default class WLSError extends Error { | ||
level: string; | ||
category: string; | ||
code: string; | ||
service: string; | ||
|
||
constructor({ | ||
level = STATUS_INDICATORS.ERROR, | ||
message = "Ein unbekannter Fehler ist aufgetreten, bitte den Administrator informieren.", | ||
category = "undefined", | ||
code = "undefined", | ||
service = "undefined", | ||
}: { | ||
level?: string; | ||
message?: string; | ||
category?: string; | ||
code?: string; | ||
service?: string; | ||
}) { | ||
// Passes the remaining parameters (including vendor-specific parameters) to the error constructor | ||
super(message); | ||
|
||
// Retains the correct stack trace for the point at which the error was triggered | ||
this.stack = new Error().stack; | ||
|
||
// User-defined information | ||
this.level = level; | ||
this.message = message; | ||
this.category = category; | ||
this.code = code; | ||
this.service = service; | ||
} | ||
|
||
static isWLSException(obj: any): obj is WLSError { | ||
return ( | ||
obj && | ||
typeof obj.category === "string" && | ||
typeof obj.code === "string" && | ||
typeof obj.message === "string" && | ||
typeof obj.service === "string" | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters