This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.ts
104 lines (80 loc) · 2.07 KB
/
errors.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
export class UberdenoError extends Error {
public statusError = 500;
}
export class CustomError extends UberdenoError {
constructor(message: string, status: number) {
super(message);
this.statusError = status;
}
}
export class MissingResource extends UberdenoError {
public statusError = 404;
constructor(resource: string) {
super(`This '${resource}' was not found.`);
}
}
export class DuplicateResource extends UberdenoError {
public statusError = 409;
constructor(resource: string) {
super(`This ${resource} already exists.`);
}
}
export class InvalidProperty extends UberdenoError {
public statusError = 400;
constructor(
property: string,
datatype: string,
) {
super(`Property '${property}' should be a ${datatype}.`);
}
}
export class MissingProperty extends UberdenoError {
public statusError = 400;
constructor(
property: string,
) {
super(`Property '${property}' is missing.`);
}
}
export class MissingBody extends UberdenoError {
public statusError = 400;
constructor() {
super("Request is missing a valid JSON body.");
}
}
export class InvalidBody extends UberdenoError {
public statusError = 400;
constructor() {
super("Request has a invalid JSON body.");
}
}
export class InvalidHeader extends UberdenoError {
public statusError = 415;
constructor() {
super("Request isn't using the 'Content-Type: application/json' header.");
}
}
export class LimitExceeded extends UberdenoError {
public statusError = 403;
constructor() {
super("GET request 'limit' may not exceed 99.");
}
}
export class InvalidAuthorization extends UberdenoError {
public statusError = 403;
constructor() {
super("Request has invalid 'Authorization' header.");
}
}
export class MissingAuthorization extends UberdenoError {
public statusError = 401;
constructor() {
super("Request is missing 'Authorization' header.");
}
}
export class MissingImplementation extends UberdenoError {
public statusError = 501;
constructor() {
super("This endpoint hasn't been implemented.");
}
}