import { BaseError } from "./base-error";

/** Errores de aplicación: orquestación, validaciones de caso de uso, seguridad, idempotencia */
export class ApplicationError extends BaseError<"application"> {
  public readonly layer = "application" as const;
  constructor(
    message: string,
    code = "APPLICATION_ERROR",
    options?: ErrorOptions & { metadata?: Record<string, unknown> }
  ) {
    super("ApplicationError", message, code, options);
  }
}

export const isApplicationError = (e: unknown): e is ApplicationError =>
  e instanceof ApplicationError;
