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
|
|
|
|
2023-06-30 10:11:26 +02:00
|
|
|
public constructor(message: string, httpCode = 400) {
|
2020-06-20 13:34:05 +02:00
|
|
|
super(message);
|
|
|
|
this.httpCode_ = httpCode;
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public get httpCode() {
|
2020-06-20 13:34:05 +02:00
|
|
|
return this.httpCode_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ErrorMethodNotAllowed extends ApiError {
|
2023-03-06 16:22:01 +02:00
|
|
|
public constructor(message = 'Method Not Allowed') {
|
2020-06-20 13:34:05 +02:00
|
|
|
super(message, 405);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ErrorNotFound extends ApiError {
|
2023-03-06 16:22:01 +02:00
|
|
|
public constructor(message = 'Not Found') {
|
2020-06-20 13:34:05 +02:00
|
|
|
super(message, 404);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ErrorForbidden extends ApiError {
|
2023-03-06 16:22:01 +02:00
|
|
|
public constructor(message = 'Forbidden') {
|
2020-06-20 13:34:05 +02:00
|
|
|
super(message, 403);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ErrorBadRequest extends ApiError {
|
2023-03-06 16:22:01 +02:00
|
|
|
public constructor(message = 'Bad Request') {
|
2020-06-20 13:34:05 +02:00
|
|
|
super(message, 400);
|
|
|
|
}
|
|
|
|
}
|