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

/** Errores de infraestructura: DB, red, serialización, proveedores externos */
export class InfrastructureError extends BaseError<"infrastructure"> {
  public readonly layer = "infrastructure" as const;
  constructor(
    message: string,
    code = "INFRASTRUCTURE_ERROR",
    options?: ErrorOptions & { metadata?: Record<string, unknown> }
  ) {
    super("InfrastructureError", message, code, options);
  }
}

export const isInfrastructureError = (e: unknown): e is InfrastructureError =>
  e instanceof InfrastructureError;
