2020-06-20 13:34:05 +02:00
|
|
|
class ApiError extends Error {
|
2020-11-12 21:13:28 +02:00
|
|
|
private httpCode_: number;
|
2020-06-20 13:34:05 +02:00
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
constructor(message: string, httpCode: number = 400) {
|
2020-06-20 13:34:05 +02:00
|
|
|
super(message);
|
|
|
|
this.httpCode_ = httpCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
get httpCode() {
|
|
|
|
return this.httpCode_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ErrorMethodNotAllowed extends ApiError {
|
|
|
|
constructor(message = 'Method Not Allowed') {
|
|
|
|
super(message, 405);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ErrorNotFound extends ApiError {
|
|
|
|
constructor(message = 'Not Found') {
|
|
|
|
super(message, 404);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ErrorForbidden extends ApiError {
|
|
|
|
constructor(message = 'Forbidden') {
|
|
|
|
super(message, 403);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ErrorBadRequest extends ApiError {
|
|
|
|
constructor(message = 'Bad Request') {
|
|
|
|
super(message, 400);
|
|
|
|
}
|
|
|
|
}
|