insufficient-balance.exception.ts 507 B

1234567891011121314151617
  1. /**
  2. * 余额不足异常 - 402 状态码(类似 Payment Required)
  3. */
  4. import { HttpException, HttpStatus } from '@nestjs/common';
  5. export class InsufficientBalanceException extends HttpException {
  6. constructor(
  7. message = '余额不足',
  8. public readonly required: bigint,
  9. public readonly available: bigint,
  10. ) {
  11. super(
  12. { statusCode: HttpStatus.PAYMENT_REQUIRED, message, required: Number(required), available: Number(available) },
  13. HttpStatus.PAYMENT_REQUIRED,
  14. );
  15. }
  16. }