import { HttpException, HttpStatus } from '@nestjs/common';

export class DomainException extends HttpException {
  constructor(message: string, status: HttpStatus = HttpStatus.BAD_REQUEST) {
    super(
      {
        statusCode: status,
        error: 'Domain Error',
        message,
      },
      status,
    );
  }
}

export class EntityNotFoundException extends DomainException {
  constructor(entity: string, id: string | bigint) {
    super(`${entity} with id ${id} not found`, HttpStatus.NOT_FOUND);
  }
}

export class InvalidOperationException extends DomainException {
  constructor(message: string) {
    super(message, HttpStatus.UNPROCESSABLE_ENTITY);
  }
}
