import { HttpException, HttpStatus } from "@nestjs/common"; /** * Thrown when a well-formed request violates a business rule that cannot be * expressed as a generic validation error. Returns HTTP 422 with a structured * body so the frontend can branch on `errorCode` without string-matching the * human-readable `message`. * * Response body shape: * ```json * { "errorCode": "SOME_CODE", "message": "Human-readable explanation." } * ``` */ export class BusinessRuleException extends HttpException { constructor( public readonly errorCode: string, message: string, ) { super({ errorCode, message }, HttpStatus.UNPROCESSABLE_ENTITY); } } export const BusinessErrorCode = { DAMAGE_EXPERT_RESEND_LIMIT_EXCEEDED: "DAMAGE_EXPERT_RESEND_LIMIT_EXCEEDED", } as const;