import { HttpException, HttpStatus } from '@nestjs/common';
import type { ErrorCodeValue, ValidationErrorDetail } from './error-codes';

export interface AppErrorResponse {
  code: ErrorCodeValue;
  details?: ValidationErrorDetail[] | unknown;
}

export class AppException extends HttpException {
  constructor(
    code: ErrorCodeValue,
    status: HttpStatus,
    details?: ValidationErrorDetail[] | unknown,
  ) {
    super({ code, details } satisfies AppErrorResponse, status);
  }
}
