refactor: remove some duplicated code

This commit is contained in:
2023-08-01 17:50:00 +02:00
parent 01697a6686
commit c5cf629482
30 changed files with 377 additions and 321 deletions

25
lib/errors.ts Normal file
View 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 };