forked from weroperking/Betterbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.ts
More file actions
32 lines (28 loc) · 713 Bytes
/
Copy patherrors.ts
File metadata and controls
32 lines (28 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export class BetterBaseError extends Error {
constructor(
message: string,
public code: string,
public statusCode = 500,
) {
super(message);
this.name = "BetterBaseError";
}
}
export class ValidationError extends BetterBaseError {
constructor(message: string) {
super(message, "VALIDATION_ERROR", 400);
this.name = "ValidationError";
}
}
export class NotFoundError extends BetterBaseError {
constructor(resource: string) {
super(`${resource} not found`, "NOT_FOUND", 404);
this.name = "NotFoundError";
}
}
export class UnauthorizedError extends BetterBaseError {
constructor(message = "Unauthorized") {
super(message, "UNAUTHORIZED", 401);
this.name = "UnauthorizedError";
}
}