import { FreshContext } from "$fresh/server.ts";

class DomainError extends Error {
  status = 500;
  render?: (ctx: FreshContext) => void;
  constructor(public statusText = "Internal Server Error") {
    super();
  }
}

class NotFoundError extends DomainError {
  override status = 404;
  constructor(public override statusText = "Not Found") {
    super();
  }
}

class BadRequestError extends DomainError {
  override status = 400;
  constructor(public override statusText = "Bad Request") {
    super();
  }
}

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

export { AccessDeniedError, BadRequestError, DomainError, NotFoundError };
