refactor: remove some duplicated code
This commit is contained in:
25
lib/errors.ts
Normal file
25
lib/errors.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { MiddlewareHandlerContext } from "$fresh/server.ts";
|
||||
|
||||
class DomainError extends Error {
|
||||
status = 500;
|
||||
render?: (ctx: MiddlewareHandlerContext) => void;
|
||||
constructor(public statusText = "Internal Server Error") {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
class NotFoundError extends DomainError {
|
||||
status = 404;
|
||||
constructor(public statusText = "Not Found") {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
class BadRequestError extends DomainError {
|
||||
status = 400;
|
||||
constructor(public statusText = "Bad Request") {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
export { BadRequestError, DomainError, NotFoundError };
|
||||
Reference in New Issue
Block a user