Added new error codes
Some checks failed
Build / Tag Version (push) Blocked by required conditions
Build / Build NPM Project (push) Has been cancelled

This commit is contained in:
Zakary Timson 2024-09-04 10:47:36 -04:00
parent 20f36cc573
commit c7dd91e9cd

View File

@ -53,6 +53,18 @@ export class UnauthorizedError extends CustomError {
} }
} }
export class PaymentRequiredError extends CustomError {
static code = 402;
constructor(message: string = 'Payment Required') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}
export class ForbiddenError extends CustomError { export class ForbiddenError extends CustomError {
static code = 403; static code = 403;
@ -77,6 +89,30 @@ export class NotFoundError extends CustomError {
} }
} }
export class MethodNotAllowedError extends CustomError {
static code = 405;
constructor(message: string = 'Method Not Allowed') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}
export class NotAcceptableError extends CustomError {
static code = 406;
constructor(message: string = 'Not Acceptable') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}
export class InternalServerError extends CustomError { export class InternalServerError extends CustomError {
static code = 500; static code = 500;
@ -88,3 +124,51 @@ export class InternalServerError extends CustomError {
return (<any>err).constructor.code == this.code; return (<any>err).constructor.code == this.code;
} }
} }
export class NotImplementedError extends CustomError {
static code = 501;
constructor(message: string = 'Not Implemented') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}
export class BadGatewayError extends CustomError {
static code = 502;
constructor(message: string = 'Bad Gateway') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}
export class ServiceUnavailableError extends CustomError {
static code = 503;
constructor(message: string = 'Service Unavailable') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}
export class GatewayTimeoutError extends CustomError {
static code = 504;
constructor(message: string = 'Gateway Timeout') {
super(message);
}
static instanceof(err: Error) {
return (<any>err).constructor.code == this.code;
}
}