/**
 * Error base para la capa de dominio.
 * Se usa para clasificar y manipular errores de dominio sin depender del texto de `message`.
 *
 * Ejemplo: throw new DomainError("Customer not found", "CUSTOMER_NOT_FOUND", { cause: err });
 */

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

/** Error base de dominio: no depende de infra ni HTTP */
export class DomainError extends BaseError<"domain"> {
  public readonly layer = "domain" as const;
  constructor(
    message: string,
    code = "DOMAIN_ERROR",
    options?: ErrorOptions & { metadata?: Record<string, unknown> }
  ) {
    super("DomainError", message, code, options);
  }
}

export const isDomainError = (e: unknown): e is DomainError => e instanceof DomainError;
