mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
Set error message optional
This commit is contained in:
@@ -8,37 +8,37 @@ export class ApiError extends Error {
|
||||
this.statusCode = options.statusCode;
|
||||
}
|
||||
|
||||
static badRequest(message: string) {
|
||||
static badRequest(message?: string) {
|
||||
return new ApiError({
|
||||
message: message || 'Bad request.',
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
static unauthorized(message: string) {
|
||||
static unauthorized(message?: string) {
|
||||
return new ApiError({
|
||||
message: message || 'Unauthorized.',
|
||||
statusCode: 401,
|
||||
});
|
||||
}
|
||||
|
||||
static forbidden(message: string) {
|
||||
static forbidden(message?: string) {
|
||||
return new ApiError({ message: message || 'Forbidden.', statusCode: 403 });
|
||||
}
|
||||
|
||||
static notFound(message: string) {
|
||||
static notFound(message?: string) {
|
||||
return new ApiError({ message: message || 'Not found.', statusCode: 404 });
|
||||
}
|
||||
|
||||
static conflict(message: string) {
|
||||
static conflict(message?: string) {
|
||||
return new ApiError({ message: message || 'Conflict.', statusCode: 409 });
|
||||
}
|
||||
|
||||
static gone(message: string) {
|
||||
static gone(message?: string) {
|
||||
return new ApiError({ message: message || 'Gone.', statusCode: 410 });
|
||||
}
|
||||
|
||||
static internal(message: string) {
|
||||
static internal(message?: string) {
|
||||
return new ApiError({
|
||||
message: message || 'Internal error.',
|
||||
statusCode: 500,
|
||||
|
||||
Reference in New Issue
Block a user