import { DomainError } from "@repo/rdx-ddd";

export class DuplicateEntityError extends DomainError {
  constructor(entity: string, field: string, value: string, options?: ErrorOptions) {
    super(`Entity '${entity}' with field '${field}' and value '${value}' already exists.`, options);
    this.name = "DuplicateEntityError";
  }
}

export const isDuplicateEntityError = (e: unknown): e is DuplicateEntityError =>
  e instanceof DuplicateEntityError;
