-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.ts
205 lines (193 loc) · 4.85 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* @description This error is fired when we cannot access an expected value
* for the full name of the repository that triggered the webhook.
*/
export class MissingRepoNameError extends Error {
constructor() {
super();
this.name = 'MissingRepoNameError';
const message = `Input is missing the repository name!`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description This error is fired when the parser receives an
* unknown/unexpected type of input.
*/
export class NoParsingMatchFoundError extends Error {
constructor() {
super();
this.name = 'NoParsingMatchFoundError';
const message = `No parsing was matched!`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description This error is fired when an unknown combination
* of PR keys are encountered.
*/
export class NoPullRequestParsingMatchError extends Error {
constructor() {
super();
this.name = 'NoPullRequestParsingMatchError';
const message = `No match while parsing pull requests!`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description This error is fired when an unknown combination
* of PR review keys are encountered.
*/
export class NoReviewParsingMatchError extends Error {
constructor() {
super();
this.name = 'NoReviewParsingMatchError';
const message = `No match while parsing reviews!`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description The error is fired when an unknown combination
* of PR comment keys are encountered.
*/
export class NoCommentParsingMatchError extends Error {
constructor() {
super();
this.name = 'NoCommentParsingMatchError';
const message = `No match while parsing comments!`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description Missing required environment variables when setting up DynamoDB.
*/
export class MissingEnvironmentVariablesDynamoError extends Error {
constructor() {
super();
this.name = 'MissingEnvironmentVariablesDynamoError';
const message = `Missing required environment variables in DynamoDB!`;
this.message = message;
this.cause = {
statusCode: 500
};
}
}
/**
* @description Used when we are unable to match a mapped key to the provided key
* when fetching data from our database.
*/
export class NoMappedKeyError extends Error {
constructor() {
super();
this.name = 'NoMappedKeyError';
const message = `No mapped key could be found!`;
this.message = message;
this.cause = {
statusCode: 500
};
}
}
/**
* @description Used when an incorrect authorization token is used.
*/
export class InvalidAuthTokenError extends Error {
constructor() {
super();
this.name = 'InvalidAuthTokenError';
const message = `The provided authorization token is incorrect.`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description Used when no parser could be mapped to the input.
*/
export class NoMatchingParserError extends Error {
constructor() {
super();
this.name = 'NoMatchingParserError';
const message = `No parser matched the input!`;
this.message = message;
this.cause = {
statusCode: 400
};
}
}
/**
* @description Used when a provided offset is not valid.
*/
export class InvalidOffsetError extends Error {
constructor() {
super();
this.name = 'InvalidOffsetError';
const message = 'Offset in hours must be provided as a number between -12 and 12!';
this.message = message;
//@ts-ignore
this.cause = {
statusCode: 400
};
}
}
/**
* @description Used when all possible input query parameters are missing.
*/
export class MissingRequiredInputParamsError extends Error {
constructor() {
super();
this.name = 'MissingRequiredInputParamsError';
const message =
'Unable to perform a query as either "to"/"from" or "last" parameters are missing.';
this.message = message;
//@ts-ignore
this.cause = {
statusCode: 500
};
}
}
/**
* @description Used when a queried date is out of range.
*/
export class OutOfRangeQueryError extends Error {
constructor() {
super();
this.name = 'OutOfRangeQueryError';
const message = 'The queried date is out of range.';
this.message = message;
//@ts-ignore
this.cause = {
statusCode: 500
};
}
}
/**
* @description Used when all mutually exclusive query parameters are used at the same time.
*/
export class TooManyInputParamsError extends Error {
constructor() {
super();
this.name = 'TooManyInputParamsError';
const message = 'To perform a query use either "to"/"from" or "last" parameters.';
this.message = message;
//@ts-ignore
this.cause = {
statusCode: 500
};
}
}