/**
 * Identity domain errors. The API layer maps these to HTTP; messages are
 * deliberately generic where leakage matters.
 */

export class InvalidCredentialsError extends Error {
  public readonly code: string;
  constructor(message?: string, code = 'INVALID_CREDENTIALS') {
    super(message ?? 'Invalid credentials');
    this.name = 'InvalidCredentialsError';
    this.code = code;
  }
}

export class EmailAlreadyRegisteredError extends Error {
  constructor() {
    super('Email already registered');
    this.name = 'EmailAlreadyRegisteredError';
  }
}

export class RateLimitedError extends Error {
  constructor(public readonly retryAfterMs: number) {
    super('Too many attempts');
    this.name = 'RateLimitedError';
  }
}
