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();
  }
}

class AccessDeniedError extends DomainError {
  status = 403;
  constructor(public statusText = "Access Denied") {
    super();
  }
}

export { AccessDeniedError, BadRequestError, DomainError, NotFoundError };
