UNPKG

jsm-exceptions

Version:

A comprehensive TypeScript exception library with HTTP status code support, detailed JSDoc documentation, and backward compatibility. Provides structured error handling for web applications and APIs.

44 lines (43 loc) 1.55 kB
import BaseException from "./base.exception"; /** * @fileoverview Unprocessable Entity exception (HTTP 422) * @author dr. Salmi <reevosolutions@gmail.com> */ /** * Exception thrown when the request is well-formed but contains semantic errors. * Corresponds to HTTP 422 Unprocessable Entity status code. * * @class UnprocessableEntityException * @extends {BaseException} * @example * ```typescript * throw new UnprocessableEntityException('Invalid data format'); * throw new UnprocessableEntityException('Business rule violation', { * email: { value: 'test@test.com', message: 'Email already exists' } * }); * ``` */ declare class UnprocessableEntityException extends BaseException { /** * Field-specific errors related to the unprocessable entity * @type {ErrorFields} */ readonly fields: ErrorFields; /** * Creates an instance of UnprocessableEntityException. * * @param {string} [message='Unprocessable Entity'] - The error message * @param {ErrorFields} [fields={}] - Field-specific errors * @param {Record<string, any>} [context] - Additional context * @memberof UnprocessableEntityException */ constructor(message?: string, fields?: ErrorFields, context?: Record<string, any>); /** * Returns a JSON representation of the unprocessable entity exception * * @returns {object} JSON representation including field errors * @memberof UnprocessableEntityException */ toJSON(): object; } export default UnprocessableEntityException;