memorium/lib/errors.ts

33 lines
743 B
TypeScript
Raw Permalink Normal View History

import { FreshContext } from "$fresh/server.ts";
2023-08-01 17:50:00 +02:00
class DomainError extends Error {
status = 500;
render?: (ctx: FreshContext) => void;
2023-08-01 17:50:00 +02:00
constructor(public statusText = "Internal Server Error") {
super();
}
}
class NotFoundError extends DomainError {
override status = 404;
constructor(public override statusText = "Not Found") {
2023-08-01 17:50:00 +02:00
super();
}
}
class BadRequestError extends DomainError {
override status = 400;
constructor(public override statusText = "Bad Request") {
2023-08-01 17:50:00 +02:00
super();
}
}
2023-08-04 22:35:25 +02:00
class AccessDeniedError extends DomainError {
override status = 403;
constructor(public override statusText = "Access Denied") {
2023-08-04 22:35:25 +02:00
super();
}
}
export { AccessDeniedError, BadRequestError, DomainError, NotFoundError };