Add function to create disciplines

+ Fix async errors
+ Extract name error
This commit is contained in:
Stephan
2022-04-29 10:35:39 +02:00
parent 3c8cea8c71
commit 9bafdebd31
5 changed files with 90 additions and 8 deletions
+1
View File
@@ -1,6 +1,7 @@
export default class ForwardableError extends Error {
// If in different context
private readonly __id = "CUSTOM_ERROR";
protected readonly __oid?: string;
public readonly status: number;
+13
View File
@@ -0,0 +1,13 @@
import ForwardableError from "./ForwardableError";
export default class NotFoundError extends ForwardableError {
protected __oid = "NOT_FOUND_ERROR";
constructor(resource?: string, pid?: string) {
super(404, `The requested ${resource ?? "resource"}${pid ? ` with PID '${pid}'` : ""} could not be found!`);
}
static isNotFoundError(err: any): err is NotFoundError {
return err.__oid === "NOT_FOUND_ERROR";
}
}