Set error message optional

This commit is contained in:
jeffvli
2022-10-12 13:47:11 -07:00
parent ea2d3ea8f1
commit 6433ccd750
+7 -7
View File
@@ -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,