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.

49 lines (48 loc) 1.71 kB
import BaseException from "./base.exception"; /** * @fileoverview Value Already Exists exception (HTTP 409) * @author dr. Salmi <reevosolutions@gmail.com> */ /** * Exception thrown when attempting to create a resource that already exists. * Corresponds to HTTP 409 Conflict status code. * * @class ValueAlreadyExistsException * @extends {BaseException} * @example * ```typescript * throw new ValueAlreadyExistsException('Email already exists'); * throw new ValueAlreadyExistsException('Username is taken', { * username: { value: 'john_doe', message: 'This username is already taken' } * }); * ``` */ declare class ValueAlreadyExistsException extends BaseException { /** * Field-specific information about the conflicting values * @type {ErrorFields} */ readonly fields?: ErrorFields; /** * Indicates if this exception was created from a Mongoose validation error * @type {boolean} */ readonly isMongoose: boolean; /** * Creates an instance of ValueAlreadyExistsException. * * @param {string} [message='Value already exists'] - The error message * @param {ErrorFields} [fields] - Field-specific information about conflicting values * @param {Record<string, any>} [context] - Additional context * @memberof ValueAlreadyExistsException */ constructor(message?: string, fields?: ErrorFields, context?: Record<string, any>); /** * Returns a JSON representation of the value already exists exception * * @returns {object} JSON representation including field information * @memberof ValueAlreadyExistsException */ toJSON(): object; } export default ValueAlreadyExistsException;