export class APIError extends Error {
  statusCode: number;
  details?: object;
  constructor(message: string, statusCode: number, details?: object) {
    super(message);
    this.name = this.constructor.name;
    this.statusCode = statusCode;
    this.details = details;
  }
}

export class ValidationError extends APIError {
  constructor(message: string, details?: object) { super(message, 400, details); }
}

export class AuthError extends APIError {
  constructor(message: string) { super(message, 401); }
}

export class ForbiddenError extends APIError {
  constructor(message: string) { super(message, 403); }
}

export class NotFoundError extends APIError {
  constructor(message: string) { super(message, 404); }
}

export class RateLimitError extends APIError {
  constructor(message: string) { super(message, 429); }
}

export class ServerError extends APIError {
  constructor(message: string) { super(message, 500); }
}
