-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapps-sdk-error.ts
More file actions
53 lines (45 loc) · 1.47 KB
/
apps-sdk-error.ts
File metadata and controls
53 lines (45 loc) · 1.47 KB
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
import { StatusCodes } from 'http-status-codes';
export enum ERROR_CODE {
GENERAL = 'general',
NOT_IMPLEMENTED = 'not implemented',
FORBIDDEN = 'forbidden',
NOT_FOUND = 'not found',
BAD_REQUEST = 'bad request',
INTERNAL_SERVER = 'internal server error',
TOO_MANY_REQUESTS = 'too many requests'
}
export class BaseError extends Error {
constructor(public errorCode: ERROR_CODE, public message: string, public status: StatusCodes) {
super(message);
}
}
export class ImplementationError extends BaseError {
constructor(public message: string) {
super(ERROR_CODE.NOT_IMPLEMENTED, message, StatusCodes.NOT_IMPLEMENTED);
}
}
export class NotFoundError extends BaseError {
constructor(public message: string) {
super(ERROR_CODE.NOT_FOUND, message, StatusCodes.NOT_FOUND);
}
}
export class BadRequestError extends BaseError {
constructor(public message: string) {
super(ERROR_CODE.BAD_REQUEST, message, StatusCodes.BAD_REQUEST);
}
}
export class InternalServerError extends BaseError {
constructor(public message: string) {
super(ERROR_CODE.INTERNAL_SERVER, message, StatusCodes.INTERNAL_SERVER_ERROR);
}
}
export class ForbiddenError extends BaseError {
constructor(public message: string) {
super(ERROR_CODE.FORBIDDEN, message, StatusCodes.FORBIDDEN);
}
}
export class TooManyRequestsError extends BaseError {
constructor(public message: string) {
super(ERROR_CODE.TOO_MANY_REQUESTS, message, StatusCodes.TOO_MANY_REQUESTS);
}
}