@bombillazo/error-x 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/error.ts"],"names":["HandlingTargets"],"mappings":";;;;;AAuBO,IAAK,eAAA,qBAAAA,gBAAAA,KAAL;AACL,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,iBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,iBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,iBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,iBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,iBAAA,cAAA,CAAA,GAAe,cAAA;AAPL,EAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;AA4JL,IAAM,qBAAA,GAAwB;AAAA,EACnC,SAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAA;;;AClLA,IAAM,cAAA,GAAiB,IAAI,GAAA,CAAI,qBAAqB,CAAA;AAsB7C,IAAM,MAAA,GAAN,MAAM,OAAA,SAAe,KAAA,CAAM;AAAA;AAAA,EAEhB,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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Y,GAAA;AAAA,MACZ,IAAA,EAAM,cAAA;AAAA,MACN,IAAA,EAAM,oBAAA;AAAA,MACN,OAAA,EAAS,cAAA;AAAA,MACT,SAAA,EAAW,qCAAA;AAAA,MACX,IAAA,EAAM;AAAA,KACR;AAAA,IAEA,+BAAA,EAAiC;AAAA,MAC/B,UAAA,EAAY,GAAA;AAAA,MACZ,IAAA,EAAM,iCAAA;AAAA,MACN,IAAA,EAAM,uCAAA;AAAA,MACN,OAAA,EAAS,iCAAA;AAAA,MACT,SAAA,EAAW,6DAAA;AAAA,MACX,IAAA,EAAM;AAAA;AACR,GACF;AACF","file":"index.js","sourcesContent":["/**\n * Metadata object containing additional context information for an error.\n * Can store any key-value pairs to provide extra debugging or business context.\n *\n * @example\n * ```typescript\n * const metadata: ErrorMetadata = {\n * userId: 123,\n * operation: 'fetchUser',\n * retryCount: 3\n * }\n * ```\n *\n * @public\n */\nexport type ErrorMetadata = Record<string, any>;\n\n/**\n * Predefined display targets for error notifications and UI feedback.\n * These enum values provide consistent, type-safe options for where errors should be displayed.\n *\n * @public\n */\nexport enum HandlingTargets {\n MODAL = 'modal',\n TOAST = 'toast',\n INLINE = 'inline',\n BANNER = 'banner',\n CONSOLE = 'console',\n LOGGER = 'logger',\n NOTIFICATION = 'notification',\n}\n\n/**\n * Display target type that allows both predefined enum values and custom strings.\n * This enables flexibility for custom UI components while providing standard options.\n *\n * @example\n * ```typescript\n * // Using predefined enum values\n * targets: [HandlingTargets.MODAL, HandlingTargets.TOAST]\n *\n * // Using custom strings\n * targets: ['custom-sidebar', 'my-notification-center']\n *\n * // Mixing both\n * targets: [HandlingTargets.MODAL, 'custom-popup', HandlingTargets.CONSOLE]\n * ```\n *\n * @public\n */\nexport type HandlingTarget = HandlingTargets | string;\n\n/**\n * Action to display notifications in specified UI targets.\n * Used to notify applications to handle error messages through the indicated display mechanisms.\n *\n * @example\n * ```typescript\n * {\n * action: 'notify',\n * payload: {\n * targets: [HandlingTargets.TOAST, 'custom-sidebar'],\n * title: 'Error occurred',\n * duration: 5000\n * }\n * }\n * ```\n *\n * @public\n */\nexport type NotifyAction = {\n action: 'notify';\n payload: {\n targets: HandlingTarget[];\n [key: string]: any;\n };\n};\n\n/**\n * Action to log out the current user when an error occurs.\n * Useful for authentication errors or session expiration.\n *\n * @example\n * ```typescript\n * {\n * action: 'logout',\n * payload: {\n * clearStorage: true,\n * redirectURL: '/login'\n * }\n * }\n * ```\n *\n * @public\n */\nexport type LogoutAction = {\n action: 'logout';\n payload?: {\n [key: string]: any;\n };\n};\n\n/**\n * Action to redirect the user to a different URL when an error occurs.\n * Commonly used for navigation after authentication errors or access denied scenarios.\n *\n * @example\n * ```typescript\n * {\n * action: 'redirect',\n * payload: {\n * redirectURL: '/login',\n * delay: 2000,\n * replace: true,\n * }\n * }\n * ```\n *\n * @public\n */\nexport type RedirectAction = {\n action: 'redirect';\n payload: {\n redirectURL: string;\n [key: string]: any;\n };\n};\n\n/**\n * Custom action type for application-specific actions.\n * This type is essential for proper TypeScript discrimination in the ErrorAction union.\n * Without this, TypeScript cannot properly distinguish between predefined and custom actions.\n *\n * @example\n * ```typescript\n * {\n * action: 'custom',\n * payload: {\n * type: 'analytics',\n * event: 'error_occurred',\n * category: 'authentication',\n * severity: 'high'\n * }\n * }\n *\n * {\n * action: 'custom',\n * payload: {\n * type: 'show-modal',\n * modalId: 'error-modal',\n * title: 'Error',\n * message: 'Something went wrong'\n * }\n * }\n * ```\n *\n * @public\n */\nexport type CustomAction = {\n action: 'custom';\n payload?: Record<string, any>;\n};\n\n/**\n * Union type of all possible error actions.\n * Includes predefined actions (NotifyAction, LogoutAction, RedirectAction)\n * and CustomAction for application-specific actions.\n *\n * @public\n */\nexport type ErrorAction = NotifyAction | LogoutAction | RedirectAction | CustomAction;\n\n/**\n * Array of valid ErrorXOptions field names.\n * This serves as the single source of truth for both runtime validation and type checking.\n *\n * @internal\n */\nexport const ERROR_X_OPTION_FIELDS = [\n 'message',\n 'name',\n 'code',\n 'uiMessage',\n 'cause',\n 'metadata',\n 'actions',\n 'httpStatus',\n 'type',\n] as const;\n\n/**\n * Union type of all valid ErrorXOptions field names.\n *\n * @public\n */\nexport type ErrorXOptionField = (typeof ERROR_X_OPTION_FIELDS)[number];\n\n/**\n * Configuration options for creating an ErrorX instance.\n * All properties are optional with sensible defaults.\n *\n * @remarks\n * **Note on design:** ErrorXOptions is a `type` instead of a `class` to provide maximum flexibility.\n * This allows you to pass plain objects without instantiation:\n *\n * ```typescript\n * // ✅ Works - plain object\n * new ErrorX({ message: 'Error', code: 'ERR' })\n *\n * // ✅ Works - object literal\n * const opts = { message: 'Error' }\n * new ErrorX(opts)\n * ```\n *\n * If ErrorXOptions were a class, you would need to instantiate it:\n *\n * ```typescript\n * // ❌ Would be required with class\n * new ErrorX(new ErrorXOptions({ message: 'Error' }))\n * ```\n *\n * The current `type` approach provides better ergonomics while still maintaining type safety.\n * The `isErrorXOptions()` validation method ensures only valid option objects are accepted.\n *\n * @public\n */\nexport type ErrorXOptions = {\n /** Technical error message (default: 'An error occurred') */\n message?: string;\n /** Error type/name (default: 'Error') */\n name?: string;\n /** Error identifier code (auto-generated from name if not provided) */\n code?: string | number;\n /** User-friendly message for UI display (default: undefined) */\n uiMessage?: string | undefined;\n /** Original error that caused this error (preserves error chain) */\n cause?: Error | unknown;\n /** Additional context and debugging information (default: undefined) */\n metadata?: ErrorMetadata;\n /** Actions to perform when this error occurs (default: undefined) */\n actions?: ErrorAction[];\n /** HTTP status code (100-599) for HTTP-related errors (default: undefined) */\n httpStatus?: number | undefined;\n /** Error type for categorization */\n type?: string | undefined;\n};\n\n/**\n * JSON-serializable representation of an ErrorX instance.\n * Used for transmitting errors over network or storing in databases.\n *\n * @example\n * ```typescript\n * const serialized: SerializableError = {\n * name: 'AuthError',\n * message: 'Authentication failed.',\n * code: 'AUTH_FAILED',\n * uiMessage: 'Please check your credentials',\n * stack: 'Error: Authentication failed.\\n at login (auth.ts:42:15)',\n * metadata: { userId: 123, loginAttempt: 3 },\n * timestamp: '2024-01-15T10:30:45.123Z',\n * actions: [\n * { action: 'logout', payload: { clearStorage: true } }\n * ],\n * cause: {\n * name: 'NetworkError',\n * message: 'Request timeout.',\n * code: 'NETWORK_TIMEOUT',\n * // ... other error properties\n * }\n * }\n * ```\n *\n * @public\n */\nexport type SerializableError = {\n /** Error type/name */\n name: string;\n /** Technical error message */\n message: string;\n /** Error identifier code */\n code: string;\n /** User-friendly message for UI display */\n uiMessage: string | undefined;\n /** Stack trace (optional) */\n stack?: string;\n /** Additional context and debugging information */\n metadata: ErrorMetadata | undefined;\n /** ISO timestamp when error was created */\n timestamp: string;\n /** Actions to perform when this error occurs */\n actions?: ErrorAction[];\n /** Serialized cause error (for error chaining) */\n cause?: SerializableError;\n /** HTTP status code for HTTP-related errors */\n httpStatus?: number;\n /** Error type for categorization */\n type?: string;\n};\n","import safeStringify from 'safe-stringify';\nimport type {\n ErrorAction,\n ErrorMetadata,\n ErrorXOptionField,\n ErrorXOptions,\n SerializableError,\n} from './types.js';\nimport { ERROR_X_OPTION_FIELDS } from './types.js';\n\n// Use the single source of truth for accepted fields\nconst acceptedFields = new Set(ERROR_X_OPTION_FIELDS);\n\n/**\n * Enhanced Error class with rich metadata, type-safe error handling, and intelligent error conversion.\n *\n * @example\n * ```typescript\n * // Basic usage\n * const error = new ErrorX({ message: 'Database connection failed' })\n *\n * // With full options\n * const error = new ErrorX({\n * message: 'User authentication failed',\n * name: 'AuthError',\n * code: 'AUTH_FAILED',\n * uiMessage: 'Please check your credentials',\n * metadata: { userId: 123, loginAttempt: 3 }\n * })\n * ```\n *\n * @public\n */\nexport class ErrorX extends Error {\n /** Error identifier code, auto-generated from name if not provided */\n public readonly code: string;\n /** User-friendly message suitable for display in UI */\n public readonly uiMessage: string | undefined;\n /** Additional context and metadata associated with the error */\n public readonly metadata: ErrorMetadata | undefined;\n /** Timestamp when the error was created */\n public readonly timestamp: Date;\n /** Error actions for UI behavior and handling */\n public readonly actions: ErrorAction[] | undefined;\n /** HTTP status code (100-599) for HTTP-related errors */\n public readonly httpStatus: number | undefined;\n /** Error type for categorization */\n public readonly type: string | undefined;\n\n /**\n * Creates a new ErrorX instance with enhanced error handling capabilities.\n *\n * @param messageOrOptions - Error message string, ErrorXOptions object, or any value to convert to ErrorX\n * @param additionalOptions - Additional options when first parameter is a string (optional)\n *\n * @example\n * ```typescript\n * // Create with string message only\n * const error1 = new ErrorX('Database query failed')\n *\n * // Create with string message and additional options\n * const error2 = new ErrorX('Database query failed', {\n * name: 'DatabaseError',\n * code: 'DB_QUERY_FAILED',\n * uiMessage: 'Unable to load data. Please try again.',\n * metadata: { query: 'SELECT * FROM users', timeout: 5000 }\n * })\n *\n * // Create with options object (backward compatible)\n * const error3 = new ErrorX({\n * message: 'Database query failed',\n * name: 'DatabaseError',\n * code: 'DB_QUERY_FAILED',\n * actions: [\n * { action: 'notify', payload: { targets: [HandlingTargets.TOAST] } }\n * ]\n * })\n *\n * // Create with unknown input (smart conversion)\n * const apiError = { message: 'User not found', code: 404 }\n * const error4 = new ErrorX(apiError)\n *\n * // Create with no options (uses defaults)\n * const error5 = new ErrorX()\n * ```\n */\n constructor(\n messageOrOptions?: string | ErrorXOptions | unknown,\n additionalOptions?: Partial<ErrorXOptions>\n ) {\n let options: ErrorXOptions = {};\n\n // Handle different input types\n if (typeof messageOrOptions === 'string') {\n // String message provided - merge with additional options\n options = {\n message: messageOrOptions,\n ...additionalOptions,\n };\n } else if (ErrorX.isErrorXOptions(messageOrOptions)) {\n // Valid ErrorXOptions object - use directly\n options = messageOrOptions;\n } else if (messageOrOptions != null) {\n // Unknown input - convert using smart conversion\n options = ErrorX.convertUnknownToOptions(messageOrOptions);\n }\n // else: undefined/null - use empty options object\n\n const formattedMessage = ErrorX.formatMessage(options.message);\n super(formattedMessage, { cause: options.cause });\n\n this.name = options.name ?? ErrorX.getDefaultName();\n this.code =\n options.code != null ? String(options.code) : ErrorX.generateDefaultCode(options.name);\n this.uiMessage = options.uiMessage;\n this.metadata = options.metadata;\n this.actions = options.actions;\n this.httpStatus = ErrorX.validateHttpStatus(options.httpStatus);\n this.type = ErrorX.validateType(options.type);\n this.timestamp = new Date();\n\n // Handle stack trace preservation\n if (options.cause instanceof Error) {\n this.stack = ErrorX.preserveOriginalStack(options.cause, this);\n } else {\n // Node.js specific stack trace capture for clean stack\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, this.constructor);\n }\n // Clean the stack to remove ErrorX constructor noise\n this.stack = ErrorX.cleanStack(this.stack);\n }\n }\n\n /**\n * Returns the default error name.\n * @returns Default error name 'Error'\n */\n private static getDefaultName(): string {\n return 'Error';\n }\n\n /**\n * Validates HTTP status code to ensure it's within valid range (100-599)\n *\n * @param status - Status code to validate\n * @returns Valid status code or undefined if invalid/not provided\n */\n private static validateHttpStatus(status?: number): number | undefined {\n if (status === undefined || status === null) {\n return undefined;\n }\n\n const statusNum = Number(status);\n\n // Validate status code is a number and within valid HTTP range\n if (Number.isNaN(statusNum) || statusNum < 100 || statusNum > 599) {\n return undefined;\n }\n\n return Math.floor(statusNum);\n }\n\n /**\n * Validates and normalizes the type field\n *\n * @param type - Type value to validate\n * @returns Validated type string or undefined if invalid/empty\n */\n private static validateType(type?: string): string | undefined {\n if (type === undefined || type === null) {\n return undefined;\n }\n\n const typeStr = String(type).trim();\n\n // Return undefined for empty strings\n if (typeStr === '') {\n return undefined;\n }\n\n return typeStr;\n }\n\n /**\n * Validates if an object is a valid ErrorXOptions object.\n * Checks that the object only contains accepted ErrorXOptions fields.\n *\n * @param value - Value to check\n * @returns True if value is a valid ErrorXOptions object\n */\n public static isErrorXOptions(value: unknown): value is ErrorXOptions {\n if (value == null || typeof value !== 'object' || Array.isArray(value)) {\n return false;\n }\n\n // If it's an Error instance, it's not ErrorXOptions\n if (value instanceof Error) {\n return false;\n }\n\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj);\n\n // Empty object is valid ErrorXOptions\n if (keys.length === 0) {\n return true;\n }\n\n // Check if all keys are in the accepted fields\n // If there's any key that's not accepted, it's not ErrorXOptions\n return keys.every((key) => acceptedFields.has(key as ErrorXOptionField));\n }\n\n /**\n * Generates a default error code from the error name.\n * Converts camelCase/PascalCase names to UPPER_SNAKE_CASE format.\n *\n * @param name - Error name to convert\n * @returns Generated error code in UPPER_SNAKE_CASE format\n *\n * @example\n * ```typescript\n * generateDefaultCode('DatabaseError') // 'DATABASE_ERROR'\n * generateDefaultCode('userAuthError') // 'USER_AUTH_ERROR'\n * generateDefaultCode('API Timeout') // 'API_TIMEOUT'\n * ```\n */\n private static generateDefaultCode(name?: string): string {\n if (!name) return 'ERROR';\n\n // Convert camelCase/PascalCase to UPPER_SNAKE_CASE\n return name\n .replace(/([a-z])([A-Z])/g, '$1_$2') // Add underscore between camelCase\n .replace(/\\s+/g, '_') // Replace spaces with underscores\n .replace(/[^a-zA-Z0-9_]/g, '') // Remove special characters\n .toUpperCase();\n }\n\n /**\n * Preserves the original error's stack trace while updating the error message.\n * Combines the new error's message with the original error's stack trace.\n *\n * @param originalError - The original error whose stack to preserve\n * @param newError - The new error whose message to use\n * @returns Combined stack trace with new error message and original stack\n */\n private static preserveOriginalStack(originalError: Error, newError: Error): string {\n if (!originalError.stack) return newError.stack || '';\n\n // Get the new error's first line (error name + message)\n const newErrorFirstLine = `${newError.name}: ${newError.message}`;\n\n // Get original stack lines (skip the first line which is the original error message)\n const originalStackLines = originalError.stack.split('\\n');\n const originalStackTrace = originalStackLines.slice(1);\n\n // Combine new error message with original stack trace\n return [newErrorFirstLine, ...originalStackTrace].join('\\n');\n }\n\n /**\n * Cleans the stack trace by removing ErrorX internal method calls.\n * This provides cleaner stack traces that focus on user code.\n *\n * @param stack - Raw stack trace to clean\n * @returns Cleaned stack trace without ErrorX internal calls\n */\n private static cleanStack(stack?: string): string {\n if (!stack) return '';\n\n const stackLines = stack.split('\\n');\n const cleanedLines: string[] = [];\n\n for (const line of stackLines) {\n // Skip lines that contain ErrorX constructor or internal methods\n if (\n line.includes('new ErrorX') ||\n line.includes('ErrorX.constructor') ||\n line.includes('ErrorX.toErrorX') ||\n line.includes('error-x/dist/') ||\n line.includes('error-x/src/error.ts')\n ) {\n continue;\n }\n cleanedLines.push(line);\n }\n\n return cleanedLines.join('\\n');\n }\n\n /**\n * Processes an error's stack trace to trim it after a specified delimiter.\n * Useful for removing irrelevant stack frames before a specific function.\n *\n * @param error - Error whose stack to process\n * @param delimiter - String to search for in stack lines\n * @returns Processed stack trace starting after the delimiter\n *\n * @example\n * ```typescript\n * const processed = ErrorX.processErrorStack(error, 'my-app-entry')\n * // Returns stack trace starting after the line containing 'my-app-entry'\n * ```\n */\n private static processErrorStack(error: Error, delimiter: string): string {\n let stack = error.stack ?? '';\n const stackLines = stack.split('\\n');\n\n // Find the index of the first line containing the delimiter\n const delimiterIndex = stackLines.findIndex((line) => line.includes(delimiter));\n\n // If the delimiter is found, return all lines after it\n if (delimiterIndex !== -1) {\n stack = stackLines.slice(delimiterIndex + 1).join('\\n');\n }\n return stack;\n }\n\n /**\n * Formats error messages with proper capitalization and punctuation.\n * Ensures consistent message formatting across all ErrorX instances.\n *\n * @param message - Raw error message to format (optional)\n * @returns Formatted message with proper capitalization and punctuation\n *\n * @example\n * ```typescript\n * formatMessage('database connection failed') // 'Database connection failed.'\n * formatMessage('user not found. please check credentials') // 'User not found. Please check credentials.'\n * formatMessage() // 'An error occurred'\n * ```\n */\n private static formatMessage(message?: string): string {\n if (!message || typeof message !== 'string' || !message.trim()) {\n return 'An error occurred';\n }\n\n // Split by sentences and capitalize each\n let formatted = message\n .split('. ')\n .map((sentence) => {\n const trimmed = sentence.trim();\n if (!trimmed) return trimmed;\n return trimmed.charAt(0).toUpperCase() + trimmed.slice(1);\n })\n .join('. ');\n\n // Add period at the end if it doesn't have proper punctuation\n const endsWithPunctuation = /[.!?)\\]]$/.test(formatted);\n if (!endsWithPunctuation) {\n formatted = `${formatted}.`;\n }\n\n return formatted;\n }\n\n /**\n * Creates a new ErrorX instance with additional metadata merged with existing metadata.\n * The original error properties are preserved while extending the metadata.\n *\n * @param additionalMetadata - Additional metadata to merge with existing metadata\n * @returns New ErrorX instance with merged metadata\n *\n * @example\n * ```typescript\n * const error = new ErrorX({\n * message: 'API request failed',\n * metadata: { endpoint: '/users' }\n * })\n *\n * const enrichedError = error.withMetadata({\n * retryCount: 3,\n * userId: 123\n * })\n * // Result: metadata = { endpoint: '/users', retryCount: 3, userId: 123 }\n * ```\n */\n public withMetadata(additionalMetadata: ErrorMetadata): ErrorX {\n const options: ErrorXOptions = {\n message: this.message,\n name: this.name,\n code: this.code,\n uiMessage: this.uiMessage,\n cause: this.cause,\n metadata: { ...(this.metadata ?? {}), ...additionalMetadata },\n httpStatus: this.httpStatus,\n type: this.type,\n };\n if (this.actions) {\n options.actions = this.actions;\n }\n const newError = new ErrorX(options);\n\n // Preserve the original stack trace\n if (this.stack) {\n newError.stack = this.stack;\n }\n return newError;\n }\n\n /**\n * Type guard that checks if a value is an ErrorX instance.\n *\n * @param value - Value to check\n * @returns True if value is an ErrorX instance, false otherwise\n *\n * @example\n * ```typescript\n * try {\n * // some operation\n * } catch (error) {\n * if (ErrorX.isErrorX(error)) {\n * // TypeScript knows error is ErrorX\n * console.log(error.code, error.metadata)\n * }\n * }\n * ```\n */\n public static isErrorX(value: unknown): value is ErrorX {\n return value instanceof ErrorX;\n }\n\n /**\n * Converts unknown input into ErrorXOptions with intelligent property extraction.\n * Handles strings, regular Error objects, API response objects, and unknown values.\n * This is a private helper method used by both the constructor and toErrorX.\n *\n * @param error - Value to convert to ErrorXOptions\n * @returns ErrorXOptions object with extracted properties\n * @internal\n */\n private static convertUnknownToOptions(error: unknown): ErrorXOptions {\n let name = '';\n let message = '';\n let code = '';\n let uiMessage = '';\n let cause: unknown;\n let metadata: ErrorMetadata = {};\n let actions: ErrorAction[] | undefined;\n let httpStatus: number | undefined;\n let type: string | undefined;\n\n if (error) {\n if (typeof error === 'string') {\n message = error;\n metadata = { originalError: error };\n } else if (error instanceof Error) {\n name = error.name;\n message = error.message;\n cause = error.cause;\n } else if (typeof error === 'object') {\n // Extract name from various properties\n if ('name' in error && error.name) name = String(error.name);\n else if ('title' in error && error.title) name = String(error.title);\n\n // Extract message from various properties\n if ('message' in error && error.message) message = String(error.message);\n else if ('details' in error && error.details) message = String(error.details);\n else if ('text' in error && error.text) message = String(error.text);\n else if ('info' in error && error.info) message = String(error.info);\n else if ('statusText' in error && error.statusText) message = String(error.statusText);\n else if ('error' in error && error.error) message = String(error.error);\n else if ('errorMessage' in error && error.errorMessage)\n message = String(error.errorMessage);\n\n // Extract code\n if ('code' in error && error.code) code = String(error.code);\n\n // Extract UI message\n if ('uiMessage' in error && error.uiMessage) uiMessage = String(error.uiMessage);\n else if ('userMessage' in error && error.userMessage) uiMessage = String(error.userMessage);\n\n // Extract actions\n if ('actions' in error && Array.isArray(error.actions)) {\n actions = error.actions as ErrorAction[];\n }\n\n let _httpStatus: unknown;\n // Extract HTTP status\n if ('httpStatus' in error) {\n _httpStatus = error.httpStatus;\n } else if ('status' in error) {\n _httpStatus = error.status;\n } else if ('statusCode' in error) {\n _httpStatus = error.statusCode;\n }\n if (_httpStatus !== undefined && _httpStatus !== null) {\n const num = typeof _httpStatus === 'number' ? _httpStatus : Number(_httpStatus);\n httpStatus = ErrorX.validateHttpStatus(num);\n }\n\n // Extract type\n if ('type' in error && error.type) {\n type = ErrorX.validateType(String(error.type));\n }\n\n // Store original object as metadata if it has additional properties\n metadata = { originalError: error };\n }\n }\n\n const options: ErrorXOptions = {\n message: message || 'Unknown error occurred',\n };\n\n if (name) options.name = name;\n if (code) options.code = code;\n if (uiMessage) options.uiMessage = uiMessage;\n if (cause) options.cause = cause;\n if (Object.keys(metadata).length > 0) options.metadata = metadata;\n if (actions && actions.length > 0) options.actions = actions;\n if (httpStatus) options.httpStatus = httpStatus;\n if (type) options.type = type;\n\n return options;\n }\n\n /**\n * Converts unknown input into an ErrorX instance with intelligent property extraction.\n * Handles strings, regular Error objects, API response objects, and unknown values.\n *\n * @param error - Value to convert to ErrorX\n * @returns ErrorX instance with extracted properties\n *\n * @example\n * ```typescript\n * // Convert string error\n * const error1 = ErrorX.toErrorX('Something went wrong')\n *\n * // Convert regular Error\n * const error2 = ErrorX.toErrorX(new Error('Database failed'))\n *\n * // Convert API response object\n * const apiError = {\n * message: 'User not found',\n * code: 'USER_404',\n * statusText: 'Not Found'\n * }\n * const error3 = ErrorX.toErrorX(apiError)\n * ```\n */\n public static toErrorX(error: unknown): ErrorX {\n if (error instanceof ErrorX) return error;\n\n const options = ErrorX.convertUnknownToOptions(error);\n return new ErrorX(options);\n }\n\n /**\n * Public wrapper for processing error stack traces with delimiter.\n * Delegates to the private processErrorStack method for implementation.\n *\n * @param error - Error whose stack to process\n * @param delimiter - String to search for in stack lines\n * @returns Processed stack trace starting after the delimiter\n *\n * @example\n * ```typescript\n * const error = new Error('Something failed')\n * const cleanStack = ErrorX.processStack(error, 'my-app-entry')\n * // Returns stack trace starting after the line containing 'my-app-entry'\n * ```\n */\n public static processStack(error: Error, delimiter: string): string {\n return ErrorX.processErrorStack(error, delimiter);\n }\n\n /**\n * Creates a new ErrorX instance with cleaned stack trace using the specified delimiter.\n * Returns the same instance if no delimiter is provided or no stack is available.\n *\n * @param delimiter - Optional string to search for in stack lines\n * @returns New ErrorX instance with cleaned stack trace, or the same instance if no cleaning needed\n *\n * @example\n * ```typescript\n * const error = new ErrorX({ message: 'Database error' })\n * const cleanedError = error.cleanStackTrace('database-layer')\n * // Returns new ErrorX with stack trace starting after 'database-layer'\n * ```\n */\n public cleanStackTrace(delimiter?: string): ErrorX {\n if (delimiter && this.stack) {\n const options: ErrorXOptions = {\n message: this.message,\n name: this.name,\n code: this.code,\n uiMessage: this.uiMessage,\n cause: this.cause,\n httpStatus: this.httpStatus,\n type: this.type,\n };\n if (this.metadata !== undefined) {\n options.metadata = this.metadata;\n }\n if (this.actions) {\n options.actions = this.actions;\n }\n const newError = new ErrorX(options);\n newError.stack = ErrorX.processErrorStack(this, delimiter);\n return newError;\n }\n return this;\n }\n\n /**\n * Converts the ErrorX instance to a detailed string representation.\n * Includes error name, message, code, timestamp, metadata, and stack trace.\n *\n * @returns Formatted string representation of the error\n *\n * @example\n * ```typescript\n * const error = new ErrorX({\n * message: 'Database connection failed',\n * name: 'DatabaseError',\n * code: 'DB_CONN_FAILED',\n * metadata: { host: 'localhost', port: 5432 }\n * })\n *\n * console.log(error.toString())\n * // Output: \"DatabaseError: Database connection failed. [DB_CONN_FAILED] (2024-01-15T10:30:45.123Z) metadata: {...}\"\n * ```\n */\n public toString(): string {\n const parts = [];\n\n // Add name and message\n parts.push(`${this.name}: ${this.message}`);\n\n // Add code if different from default\n if (this.code && this.code !== 'ERROR') {\n parts.push(`[${this.code}]`);\n }\n\n // Add timestamp\n parts.push(`(${this.timestamp.toISOString()})`);\n\n // Add metadata if present\n if (this.metadata && Object.keys(this.metadata).length > 0) {\n const metadataStr = safeStringify(this.metadata);\n parts.push(`metadata: ${metadataStr}`);\n }\n\n let result = parts.join(' ');\n\n // Add stack trace if available\n if (this.stack) {\n result += `\\n${this.stack}`;\n }\n\n return result;\n }\n\n /**\n * Serializes the ErrorX instance to a JSON-compatible object.\n * Recursively serializes the error chain and handles ErrorX or regular Error causes.\n *\n * @returns Serializable object representation of the error\n *\n * @example\n * ```typescript\n * const error = new ErrorX({\n * message: 'API request failed',\n * code: 'API_ERROR',\n * metadata: { endpoint: '/users', status: 500 }\n * })\n *\n * const serialized = error.toJSON()\n * // Can be safely passed to JSON.stringify() or sent over network\n * ```\n */\n public toJSON(): SerializableError {\n // Handle metadata serialization with circular reference protection\n\n // Use safe stringify to parse the metadata and remove circular references\n const safeMetadata: ErrorMetadata | undefined = this.metadata\n ? JSON.parse(safeStringify(this.metadata))\n : undefined;\n\n const serialized: SerializableError = {\n name: this.name,\n message: this.message,\n code: this.code,\n uiMessage: this.uiMessage,\n metadata: safeMetadata,\n timestamp: this.timestamp.toISOString(),\n };\n\n // Include actions if present\n if (this.actions && this.actions.length > 0) {\n // Use safe stringify to parse the actions and remove circular references\n const stringified = safeStringify(this.actions);\n serialized.actions = JSON.parse(stringified);\n }\n\n // Include httpStatus if present\n if (this.httpStatus !== undefined) {\n serialized.httpStatus = this.httpStatus;\n }\n\n // Include type if present\n if (this.type !== undefined) {\n serialized.type = this.type;\n }\n\n // Include stack if available\n if (this.stack) {\n serialized.stack = this.stack;\n }\n\n // Recursively serialize cause if it's an ErrorX\n if (this.cause) {\n if (this.cause instanceof ErrorX) {\n serialized.cause = this.cause.toJSON();\n } else if (this.cause instanceof Error) {\n const causeData: SerializableError = {\n name: this.cause.name,\n message: this.cause.message,\n code: 'ERROR',\n uiMessage: undefined,\n metadata: {},\n timestamp: new Date().toISOString(),\n };\n if (this.cause.stack) {\n causeData.stack = this.cause.stack;\n }\n serialized.cause = causeData;\n }\n }\n\n return serialized;\n }\n\n /**\n * Deserializes a JSON object back into an ErrorX instance.\n * Recursively reconstructs the error chain and restores all properties.\n *\n * @param serialized - Serialized error object to deserialize\n * @returns Reconstructed ErrorX instance with restored properties\n *\n * @example\n * ```typescript\n * const serializedError = {\n * name: 'DatabaseError',\n * message: 'Connection failed.',\n * code: 'DB_CONN_FAILED',\n * uiMessage: 'Database is temporarily unavailable',\n * metadata: { host: 'localhost' },\n * timestamp: '2024-01-15T10:30:45.123Z'\n * }\n *\n * const error = ErrorX.fromJSON(serializedError)\n * // Fully restored ErrorX instance with all properties\n * ```\n */\n public static fromJSON(serialized: SerializableError): ErrorX {\n const options: ErrorXOptions = {\n message: serialized.message,\n name: serialized.name,\n code: serialized.code,\n uiMessage: serialized.uiMessage,\n httpStatus: serialized.httpStatus,\n type: serialized.type,\n };\n if (serialized.metadata !== undefined) {\n options.metadata = serialized.metadata;\n }\n\n if (serialized.actions && serialized.actions.length > 0) {\n options.actions = serialized.actions;\n }\n\n const error = new ErrorX(options);\n\n // Restore stack and timestamp\n if (serialized.stack) {\n error.stack = serialized.stack;\n }\n // Use Object.defineProperty to set readonly properties\n Object.defineProperty(error, 'timestamp', {\n value: new Date(serialized.timestamp),\n writable: false,\n });\n\n // Restore cause chain\n if (serialized.cause) {\n Object.defineProperty(error, 'cause', {\n value: ErrorX.fromJSON(serialized.cause),\n writable: false,\n });\n }\n\n return error;\n }\n\n /**\n * HTTP error presets for common HTTP status codes.\n *\n * ## Features\n * - **Pre-configured error templates** for common HTTP status codes (400-511)\n * - **Type-safe** with TypeScript support\n * - **Fully customizable** via destructuring and override pattern\n * - **User-friendly messages** included for all presets\n * - **Categorized by type** - all HTTP presets include `type: 'http'`\n *\n * ## Usage Patterns\n *\n * ### 1. Direct Usage\n * Use a preset as-is without any modifications:\n * ```typescript\n * throw new ErrorX(ErrorX.HTTP.NOT_FOUND)\n * // Result: 404 error with default message and UI message\n * ```\n *\n * ### 2. Override Specific Fields\n * Customize the error while keeping other preset values:\n * ```typescript\n * throw new ErrorX({\n * ...ErrorX.HTTP.NOT_FOUND,\n * message: 'User not found',\n * metadata: { userId: 123 }\n * })\n * // Result: 404 error with custom message but keeps httpStatus, code, name, uiMessage, type\n * ```\n *\n * ### 3. Add Metadata and Actions\n * Enhance presets with additional context and behaviors:\n * ```typescript\n * throw new ErrorX({\n * ...ErrorX.HTTP.UNAUTHORIZED,\n * metadata: { attemptedAction: 'viewProfile', userId: 456 },\n * actions: [\n * { action: 'logout', payload: { clearStorage: true } },\n * { action: 'redirect', payload: { redirectURL: '/login' } }\n * ]\n * })\n * ```\n *\n * ### 4. Add Error Cause\n * Chain errors by adding a cause:\n * ```typescript\n * try {\n * // some operation\n * } catch (originalError) {\n * throw new ErrorX({\n * ...ErrorX.HTTP.INTERNAL_SERVER_ERROR,\n * cause: originalError,\n * metadata: { operation: 'database-query' }\n * })\n * }\n * ```\n *\n * ## Common HTTP Presets\n *\n * ### 4xx Client Errors\n * - `BAD_REQUEST` (400) - Invalid request data\n * - `UNAUTHORIZED` (401) - Authentication required\n * - `FORBIDDEN` (403) - Insufficient permissions\n * - `NOT_FOUND` (404) - Resource not found\n * - `METHOD_NOT_ALLOWED` (405) - HTTP method not allowed\n * - `CONFLICT` (409) - Resource conflict\n * - `UNPROCESSABLE_ENTITY` (422) - Validation failed\n * - `TOO_MANY_REQUESTS` (429) - Rate limit exceeded\n *\n * ### 5xx Server Errors\n * - `INTERNAL_SERVER_ERROR` (500) - Unexpected server error\n * - `NOT_IMPLEMENTED` (501) - Feature not implemented\n * - `BAD_GATEWAY` (502) - Upstream server error\n * - `SERVICE_UNAVAILABLE` (503) - Service temporarily down\n * - `GATEWAY_TIMEOUT` (504) - Upstream timeout\n *\n * @example\n * ```typescript\n * // API endpoint example\n * app.get('/users/:id', async (req, res) => {\n * const user = await db.users.findById(req.params.id)\n *\n * if (!user) {\n * throw new ErrorX({\n * ...ErrorX.HTTP.NOT_FOUND,\n * message: 'User not found',\n * metadata: { userId: req.params.id }\n * })\n * }\n *\n * res.json(user)\n * })\n *\n * // Authentication middleware example\n * const requireAuth = (req, res, next) => {\n * if (!req.user) {\n * throw new ErrorX({\n * ...ErrorX.HTTP.UNAUTHORIZED,\n * actions: [\n * { action: 'redirect', payload: { redirectURL: '/login' } }\n * ]\n * })\n * }\n * next()\n * }\n *\n * // Rate limiting example\n * if (isRateLimited(req.ip)) {\n * throw new ErrorX({\n * ...ErrorX.HTTP.TOO_MANY_REQUESTS,\n * metadata: {\n * ip: req.ip,\n * retryAfter: 60\n * }\n * })\n * }\n * ```\n *\n * @public\n */\n public static readonly HTTP = {\n // 4xx Client Errors\n BAD_REQUEST: {\n httpStatus: 400,\n code: 'BAD_REQUEST',\n name: 'Bad Request Error',\n message: 'bad request',\n uiMessage: 'The request could not be processed. Please check your input and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n UNAUTHORIZED: {\n httpStatus: 401,\n code: 'UNAUTHORIZED',\n name: 'Unauthorized Error',\n message: 'unauthorized',\n uiMessage: 'Authentication required. Please log in to continue.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n PAYMENT_REQUIRED: {\n httpStatus: 402,\n code: 'PAYMENT_REQUIRED',\n name: 'Payment Required Error',\n message: 'payment required',\n uiMessage: 'Payment is required to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n FORBIDDEN: {\n httpStatus: 403,\n code: 'FORBIDDEN',\n name: 'Forbidden Error',\n message: 'forbidden',\n uiMessage: 'You do not have permission to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n NOT_FOUND: {\n httpStatus: 404,\n code: 'NOT_FOUND',\n name: 'Not Found Error',\n message: 'not found',\n uiMessage: 'The requested resource could not be found.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n METHOD_NOT_ALLOWED: {\n httpStatus: 405,\n code: 'METHOD_NOT_ALLOWED',\n name: 'Method Not Allowed Error',\n message: 'method not allowed',\n uiMessage: 'This action is not allowed for the requested resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n NOT_ACCEPTABLE: {\n httpStatus: 406,\n code: 'NOT_ACCEPTABLE',\n name: 'Not Acceptable Error',\n message: 'not acceptable',\n uiMessage: 'The requested format is not supported.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n PROXY_AUTHENTICATION_REQUIRED: {\n httpStatus: 407,\n code: 'PROXY_AUTHENTICATION_REQUIRED',\n name: 'Proxy Authentication Required Error',\n message: 'proxy authentication required',\n uiMessage: 'Proxy authentication is required to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n REQUEST_TIMEOUT: {\n httpStatus: 408,\n code: 'REQUEST_TIMEOUT',\n name: 'Request Timeout Error',\n message: 'request timeout',\n uiMessage: 'The request took too long to complete. Please try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n CONFLICT: {\n httpStatus: 409,\n code: 'CONFLICT',\n name: 'Conflict Error',\n message: 'conflict',\n uiMessage: 'The request conflicts with the current state. Please refresh and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n GONE: {\n httpStatus: 410,\n code: 'GONE',\n name: 'Gone Error',\n message: 'gone',\n uiMessage: 'This resource is no longer available.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n LENGTH_REQUIRED: {\n httpStatus: 411,\n code: 'LENGTH_REQUIRED',\n name: 'Length Required Error',\n message: 'length required',\n uiMessage: 'The request is missing required length information.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n PRECONDITION_FAILED: {\n httpStatus: 412,\n code: 'PRECONDITION_FAILED',\n name: 'Precondition Failed Error',\n message: 'precondition failed',\n uiMessage: 'A required condition was not met. Please try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n PAYLOAD_TOO_LARGE: {\n httpStatus: 413,\n code: 'PAYLOAD_TOO_LARGE',\n name: 'Payload Too Large Error',\n message: 'payload too large',\n uiMessage: 'The request is too large. Please reduce the size and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n URI_TOO_LONG: {\n httpStatus: 414,\n code: 'URI_TOO_LONG',\n name: 'URI Too Long Error',\n message: 'URI too long',\n uiMessage: 'The request URL is too long.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n UNSUPPORTED_MEDIA_TYPE: {\n httpStatus: 415,\n code: 'UNSUPPORTED_MEDIA_TYPE',\n name: 'Unsupported Media Type Error',\n message: 'unsupported media type',\n uiMessage: 'The file type is not supported.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n RANGE_NOT_SATISFIABLE: {\n httpStatus: 416,\n code: 'RANGE_NOT_SATISFIABLE',\n name: 'Range Not Satisfiable Error',\n message: 'range not satisfiable',\n uiMessage: 'The requested range cannot be satisfied.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n EXPECTATION_FAILED: {\n httpStatus: 417,\n code: 'EXPECTATION_FAILED',\n name: 'Expectation Failed Error',\n message: 'expectation failed',\n uiMessage: 'The server cannot meet the requirements of the request.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n IM_A_TEAPOT: {\n httpStatus: 418,\n code: 'IM_A_TEAPOT',\n name: 'Im A Teapot Error',\n message: \"i'm a teapot\",\n uiMessage: \"I'm a teapot and cannot brew coffee.\",\n type: 'http',\n } satisfies ErrorXOptions,\n\n UNPROCESSABLE_ENTITY: {\n httpStatus: 422,\n code: 'UNPROCESSABLE_ENTITY',\n name: 'Unprocessable Entity Error',\n message: 'unprocessable entity',\n uiMessage: 'The request contains invalid data. Please check your input.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n LOCKED: {\n httpStatus: 423,\n code: 'LOCKED',\n name: 'Locked Error',\n message: 'locked',\n uiMessage: 'This resource is locked and cannot be modified.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n FAILED_DEPENDENCY: {\n httpStatus: 424,\n code: 'FAILED_DEPENDENCY',\n name: 'Failed Dependency Error',\n message: 'failed dependency',\n uiMessage: 'The request failed due to a dependency error.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n TOO_EARLY: {\n httpStatus: 425,\n code: 'TOO_EARLY',\n name: 'Too Early Error',\n message: 'too early',\n uiMessage: 'The request was sent too early. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n UPGRADE_REQUIRED: {\n httpStatus: 426,\n code: 'UPGRADE_REQUIRED',\n name: 'Upgrade Required Error',\n message: 'upgrade required',\n uiMessage: 'Please upgrade to continue using this service.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n PRECONDITION_REQUIRED: {\n httpStatus: 428,\n code: 'PRECONDITION_REQUIRED',\n name: 'Precondition Required Error',\n message: 'precondition required',\n uiMessage: 'Required conditions are missing from the request.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n TOO_MANY_REQUESTS: {\n httpStatus: 429,\n code: 'TOO_MANY_REQUESTS',\n name: 'Too Many Requests Error',\n message: 'too many requests',\n uiMessage: 'You have made too many requests. Please wait and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n REQUEST_HEADER_FIELDS_TOO_LARGE: {\n httpStatus: 431,\n code: 'REQUEST_HEADER_FIELDS_TOO_LARGE',\n name: 'Request Header Fields Too Large Error',\n message: 'request header fields too large',\n uiMessage: 'The request headers are too large.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n UNAVAILABLE_FOR_LEGAL_REASONS: {\n httpStatus: 451,\n code: 'UNAVAILABLE_FOR_LEGAL_REASONS',\n name: 'Unavailable For Legal Reasons Error',\n message: 'unavailable for legal reasons',\n uiMessage: 'This content is unavailable for legal reasons.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n // 5xx Server Errors\n INTERNAL_SERVER_ERROR: {\n httpStatus: 500,\n code: 'INTERNAL_SERVER_ERROR',\n name: 'Internal Server Error',\n message: 'internal server error',\n uiMessage: 'An unexpected error occurred. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n NOT_IMPLEMENTED: {\n httpStatus: 501,\n code: 'NOT_IMPLEMENTED',\n name: 'Not Implemented Error',\n message: 'not implemented',\n uiMessage: 'This feature is not yet available.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n BAD_GATEWAY: {\n httpStatus: 502,\n code: 'BAD_GATEWAY',\n name: 'Bad Gateway Error',\n message: 'bad gateway',\n uiMessage: 'Unable to connect to the server. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n SERVICE_UNAVAILABLE: {\n httpStatus: 503,\n code: 'SERVICE_UNAVAILABLE',\n name: 'Service Unavailable Error',\n message: 'service unavailable',\n uiMessage: 'The service is temporarily unavailable. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n GATEWAY_TIMEOUT: {\n httpStatus: 504,\n code: 'GATEWAY_TIMEOUT',\n name: 'Gateway Timeout Error',\n message: 'gateway timeout',\n uiMessage: 'The server took too long to respond. Please try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n HTTP_VERSION_NOT_SUPPORTED: {\n httpStatus: 505,\n code: 'HTTP_VERSION_NOT_SUPPORTED',\n name: 'HTTP Version Not Supported Error',\n message: 'HTTP version not supported',\n uiMessage: 'Your browser version is not supported.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n VARIANT_ALSO_NEGOTIATES: {\n httpStatus: 506,\n code: 'VARIANT_ALSO_NEGOTIATES',\n name: 'Variant Also Negotiates Error',\n message: 'variant also negotiates',\n uiMessage: 'The server has an internal configuration error.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n INSUFFICIENT_STORAGE: {\n httpStatus: 507,\n code: 'INSUFFICIENT_STORAGE',\n name: 'Insufficient Storage Error',\n message: 'insufficient storage',\n uiMessage: 'The server has insufficient storage to complete the request.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n LOOP_DETECTED: {\n httpStatus: 508,\n code: 'LOOP_DETECTED',\n name: 'Loop Detected Error',\n message: 'loop detected',\n uiMessage: 'The server detected an infinite loop.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n NOT_EXTENDED: {\n httpStatus: 510,\n code: 'NOT_EXTENDED',\n name: 'Not Extended Error',\n message: 'not extended',\n uiMessage: 'Additional extensions are required.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n NETWORK_AUTHENTICATION_REQUIRED: {\n httpStatus: 511,\n code: 'NETWORK_AUTHENTICATION_REQUIRED',\n name: 'Network Authentication Required Error',\n message: 'network authentication required',\n uiMessage: 'Network authentication is required to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n } as const;\n}\n"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/error.ts","../src/presets.ts"],"names":[],"mappings":";;;;;AA2BO,IAAM,qBAAA,GAAwB;AAAA,EACnC,SAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;;;AC5BA,IAAM,cAAA,GAAiB,IAAI,GAAA,CAAI,qBAAqB,CAAA;AA6D7C,IAAM,MAAA,GAAN,MAAM,OAAA,SAAkE,KAAA,CAAM;AAAA;AAAA,EAEnF,OAAe,OAAA,GAA+B,IAAA;AAAA;AAAA,EAGvC,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,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+B;AAAA,IAC7B,UAAA,EAAY,GAAA;AAAA,IACZ,IAAA,EAAM,iCAAA;AAAA,IACN,IAAA,EAAM,uCAAA;AAAA,IACN,OAAA,EAAS,kCAAA;AAAA,IACT,SAAA,EAAW,6DAAA;AAAA,IACX,IAAA,EAAM;AAAA;AAEV","file":"index.js","sourcesContent":["/**\n * Metadata object containing additional context information for an error.\n * Can store any key-value pairs to provide extra debugging or business context.\n *\n * Users can use metadata to store application-specific behavior instructions if needed:\n * ```typescript\n * const metadata = {\n * userId: 123,\n * operation: 'fetchUser',\n * retryCount: 3,\n * // Application-specific behavior can be stored here:\n * shouldNotify: true,\n * notifyTargets: ['toast', 'banner'],\n * redirectTo: '/login'\n * }\n * ```\n *\n * @public\n */\nexport type ErrorXMetadata = Record<string, unknown>;\n\n/**\n * Array of valid ErrorXOptions field names.\n * This serves as the single source of truth for both runtime validation and type checking.\n *\n * @internal\n */\nexport const ERROR_X_OPTION_FIELDS = [\n 'message',\n 'name',\n 'code',\n 'uiMessage',\n 'cause',\n 'metadata',\n 'httpStatus',\n 'type',\n 'sourceUrl',\n 'docsUrl',\n 'source',\n] as const;\n\n/**\n * Union type of all valid ErrorXOptions field names.\n *\n * @public\n */\nexport type ErrorXOptionField = (typeof ERROR_X_OPTION_FIELDS)[number];\n\n/**\n * Configuration options for creating an ErrorX instance.\n * All properties are optional with sensible defaults.\n *\n * @remarks\n * **Note on design:** ErrorXOptions is a `type` instead of a `class` to provide maximum flexibility.\n * This allows you to pass plain objects without instantiation:\n *\n * ```typescript\n * // ✅ Works - plain object\n * new ErrorX({ message: 'Error', code: 'ERR' })\n *\n * // ✅ Works - object literal\n * const opts = { message: 'Error' }\n * new ErrorX(opts)\n *\n * // ✅ Works - with type-safe metadata\n * type MyMeta = { userId: number; action: string };\n * new ErrorX<MyMeta>({ metadata: { userId: 123, action: 'login' } })\n * ```\n *\n * If ErrorXOptions were a class, you would need to instantiate it:\n *\n * ```typescript\n * // ❌ Would be required with class\n * new ErrorX(new ErrorXOptions({ message: 'Error' }))\n * ```\n *\n * The current `type` approach provides better ergonomics while still maintaining type safety.\n * The `isErrorXOptions()` validation method ensures only valid option objects are accepted.\n *\n * @public\n */\nexport type ErrorXOptions<TMetadata extends ErrorXMetadata = ErrorXMetadata> = {\n /** Technical error message (default: 'An error occurred') */\n message?: string;\n /** Error type/name (default: 'Error') */\n name?: string;\n /** Error identifier code (auto-generated from name if not provided) */\n code?: string | number;\n /** User-friendly message for UI display */\n uiMessage?: string | undefined;\n /** Original error that caused this error (preserves error chain, will be converted to ErrorXCause format) */\n cause?: ErrorXCause | Error | unknown;\n /** Additional context and debugging information */\n metadata?: TMetadata | undefined;\n /** HTTP status code (100-599) for HTTP-related errors */\n httpStatus?: number | undefined;\n /** Error type for categorization */\n type?: string | undefined;\n /** Source URL related to the error (API endpoint, page URL, resource URL) */\n sourceUrl?: string | undefined;\n /** Documentation URL for this specific error */\n docsUrl?: string | undefined;\n /** Where the error originated (service name, module, component) */\n source?: string | undefined;\n};\n\n/**\n * Simplified representation of an error cause for serialization.\n * Used to store error chain information without circular references.\n *\n * @public\n */\nexport type ErrorXCause = {\n /** Error message */\n message: string;\n /** Error name (optional) */\n name?: string;\n /** Stack trace (optional) */\n stack?: string;\n};\n\n/**\n * JSON-serializable representation of an ErrorX instance.\n * Used for transmitting errors over network or storing in databases.\n *\n * @example\n * ```typescript\n * const serialized: SerializableError = {\n * name: 'AuthError',\n * message: 'Authentication failed.',\n * code: 'AUTH_FAILED',\n * uiMessage: 'Please check your credentials',\n * stack: 'Error: Authentication failed.\\n at login (auth.ts:42:15)',\n * metadata: { userId: 123, loginAttempt: 3 },\n * timestamp: '2024-01-15T10:30:45.123Z',\n * cause: {\n * name: 'NetworkError',\n * message: 'Request timeout.',\n * stack: '...'\n * },\n * sourceUrl: 'https://api.example.com/auth',\n * docsUrl: 'https://docs.example.com/errors#auth-failed',\n * source: 'auth-service'\n * }\n * ```\n *\n * @public\n */\nexport type ErrorXSerialized = {\n /** Error type/name */\n name: string;\n /** Technical error message */\n message: string;\n /** Error identifier code */\n code: string;\n /** User-friendly message for UI display */\n uiMessage: string | undefined;\n /** Stack trace (optional) */\n stack?: string;\n /** Additional context and debugging information */\n metadata: ErrorXMetadata | undefined;\n /** ISO timestamp when error was created */\n timestamp: string;\n /** Simplified cause error (for error chaining) */\n cause?: ErrorXCause;\n /** HTTP status code for HTTP-related errors */\n httpStatus?: number;\n /** Error type for categorization */\n type?: string;\n /** Source URL related to the error */\n sourceUrl?: string;\n /** Documentation URL for this error */\n docsUrl?: string;\n /** Where the error originated */\n source?: string;\n};\n","import safeStringify from 'safe-stringify';\nimport type {\n ErrorXCause,\n ErrorXMetadata,\n ErrorXOptionField,\n ErrorXOptions,\n ErrorXSerialized,\n} from './types.js';\nimport { ERROR_X_OPTION_FIELDS } from './types.js';\n\n// Use the single source of truth for accepted fields\nconst acceptedFields = new Set(ERROR_X_OPTION_FIELDS);\n\n/**\n * Configuration interface for ErrorX global settings\n *\n * @public\n */\nexport interface ErrorXConfig {\n /** Default source identifier for all errors (e.g., service name, module name) */\n source?: string;\n /** Base URL for error documentation */\n docsBaseURL?: string;\n /** Mapping of error codes to documentation paths */\n docsMap?: Record<string, string>;\n /**\n * Control stack trace cleaning behavior\n * - true: Enable automatic stack trace cleaning (default)\n * - false: Disable stack trace cleaning entirely\n * - string[]: Custom patterns to match and remove from stack traces\n */\n cleanStack?: boolean | string[];\n}\n\n/**\n * Enhanced Error class with rich metadata, type-safe error handling, and intelligent error conversion.\n *\n * @example\n * ```typescript\n * // Configure globally (optional)\n * ErrorX.configure({\n * source: 'my-service',\n * docsBaseURL: 'https://docs.example.com',\n * docsMap: {\n * 'AUTH_FAILED': 'errors/authentication',\n * 'DB_ERROR': 'errors/database'\n * }\n * })\n *\n * // Basic usage\n * const error = new ErrorX({ message: 'Database connection failed' })\n *\n * // With full options\n * const error = new ErrorX({\n * message: 'User authentication failed',\n * name: 'AuthError',\n * code: 'AUTH_FAILED',\n * uiMessage: 'Please check your credentials',\n * metadata: { userId: 123, loginAttempt: 3 }\n * })\n *\n * // With type-safe metadata\n * type MyMetadata = { userId: number; action: string };\n * const error = new ErrorX<MyMetadata>({\n * message: 'Action failed',\n * metadata: { userId: 123, action: 'delete' }\n * })\n * // error.metadata?.userId is typed as number\n * ```\n *\n * @public\n */\nexport class ErrorX<TMetadata extends ErrorXMetadata = ErrorXMetadata> extends Error {\n /** Global configuration for all ErrorX instances */\n private static _config: ErrorXConfig | null = null;\n\n /** Error identifier code, auto-generated from name if not provided */\n public code: string;\n /** User-friendly message suitable for display in UI */\n public uiMessage: string | undefined;\n /** Additional context and metadata associated with the error */\n public metadata: TMetadata | undefined;\n /** Timestamp when the error was created */\n public timestamp: Date;\n /** HTTP status code (100-599) for HTTP-related errors */\n public httpStatus: number | undefined;\n /** Error type for categorization */\n public type: string | undefined;\n /** Source URL related to the error (API endpoint, page URL, resource URL) */\n public sourceUrl: string | undefined;\n /** Documentation URL for this specific error */\n public docsUrl: string | undefined;\n /** Where the error originated (service name, module, component) */\n public source: string | undefined;\n /** Original error that caused this error (preserves error chain) */\n public cause: ErrorXCause | undefined;\n\n /**\n * Creates a new ErrorX instance with enhanced error handling capabilities.\n *\n * @param messageOrOptions - Error message string or ErrorXOptions object (optional)\n *\n * @example\n * ```typescript\n * // Create with default message\n * const error1 = new ErrorX()\n *\n * // Create with string message only\n * const error2 = new ErrorX('Database query failed')\n *\n * // Create with options object\n * const error3 = new ErrorX({\n * message: 'Database query failed',\n * name: 'DatabaseError',\n * code: 'DB_QUERY_FAILED',\n * uiMessage: 'Unable to load data. Please try again.',\n * metadata: { query: 'SELECT * FROM users', timeout: 5000 }\n * })\n *\n * // With type-safe metadata\n * type MyMeta = { userId: number };\n * const error4 = new ErrorX<MyMeta>({\n * message: 'User action failed',\n * metadata: { userId: 123 }\n * })\n *\n * // For converting unknown errors, use ErrorX.from()\n * const apiError = { message: 'User not found', code: 404 }\n * const error5 = ErrorX.from(apiError)\n * ```\n */\n constructor(messageOrOptions?: string | ErrorXOptions<TMetadata>) {\n let options: ErrorXOptions<TMetadata> = {};\n\n // Handle different input types\n if (typeof messageOrOptions === 'string') {\n // String message provided\n options = { message: messageOrOptions };\n } else if (messageOrOptions != null) {\n // ErrorXOptions object - use directly\n options = messageOrOptions;\n }\n // else: undefined/null - use empty options object\n\n // Read environment config for defaults\n const envConfig = ErrorX.getConfig();\n\n // Use default message if not provided or if it's empty/whitespace-only\n const message = options.message?.trim() ? options.message : 'An error occurred';\n\n // Convert cause to ErrorXCause format\n const convertedCause = ErrorX.toErrorXCause(options.cause);\n\n // Call super without cause since we'll set it manually in ErrorXCause format\n super(message);\n\n // Set cause in ErrorXCause format\n this.cause = convertedCause;\n\n this.name = options.name ?? ErrorX.getDefaultName();\n this.code =\n options.code != null ? String(options.code) : ErrorX.generateDefaultCode(options.name);\n this.uiMessage = options.uiMessage;\n this.metadata = options.metadata;\n this.httpStatus = ErrorX.validateHttpStatus(options.httpStatus);\n this.type = ErrorX.validateType(options.type);\n this.timestamp = new Date();\n\n // Set new fields\n this.sourceUrl = options.sourceUrl;\n this.source = options.source ?? envConfig?.source;\n\n // Auto-generate docsUrl from environment config if available\n let generatedDocsUrl: string | undefined;\n if (envConfig?.docsBaseURL && envConfig?.docsMap && this.code) {\n const docPath = envConfig.docsMap[this.code];\n if (docPath) {\n // Normalize URL construction to avoid double slashes\n const base = envConfig.docsBaseURL.replace(/\\/+$/, ''); // Remove trailing slashes\n const path = docPath.replace(/^\\/+/, ''); // Remove leading slashes\n generatedDocsUrl = `${base}/${path}`;\n }\n }\n this.docsUrl = options.docsUrl ?? generatedDocsUrl;\n\n // Handle stack trace preservation\n if (convertedCause?.stack) {\n this.stack = ErrorX.preserveOriginalStackFromCause(convertedCause, this);\n } else {\n // Node.js specific stack trace capture for clean stack\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, this.constructor);\n }\n // Clean the stack to remove ErrorX constructor noise\n this.stack = ErrorX.cleanStack(this.stack);\n }\n }\n\n /**\n * Returns the default error name.\n * @returns Default error name 'Error'\n */\n private static getDefaultName(): string {\n return 'Error';\n }\n\n /**\n * Converts any value to ErrorXCause format.\n * @param value - Value to convert to ErrorXCause\n * @returns ErrorXCause object or undefined if value is null/undefined\n */\n private static toErrorXCause(value: unknown): ErrorXCause | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n\n if (value instanceof Error) {\n const cause: ErrorXCause = {\n message: value.message,\n };\n if (value.name) {\n cause.name = value.name;\n }\n if (value.stack) {\n cause.stack = value.stack;\n }\n return cause;\n }\n\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>;\n const cause: ErrorXCause = {\n message: String(obj.message || obj),\n };\n if (obj.name) {\n cause.name = String(obj.name);\n }\n if (obj.stack) {\n cause.stack = String(obj.stack);\n }\n return cause;\n }\n\n // Handle primitives\n return {\n message: String(value),\n };\n }\n\n /**\n * Configure global ErrorX settings.\n * This method allows you to set defaults for all ErrorX instances.\n *\n * @param config - Configuration object\n *\n * @example\n * ```typescript\n * ErrorX.configure({\n * source: 'my-api-service',\n * docsBaseURL: 'https://docs.example.com/errors',\n * docsMap: {\n * 'AUTH_FAILED': 'authentication-errors',\n * 'DB_ERROR': 'database-errors'\n * }\n * })\n * ```\n */\n public static configure(config: ErrorXConfig): void {\n ErrorX._config = { ...(ErrorX._config || {}), ...config };\n }\n\n /**\n * Get the current global configuration.\n * Returns null if no configuration has been set.\n */\n public static getConfig(): ErrorXConfig | null {\n return ErrorX._config;\n }\n\n /**\n * Validates HTTP status code to ensure it's within valid range (100-599)\n *\n * @param status - Status code to validate\n * @returns Valid status code or undefined if invalid/not provided\n */\n private static validateHttpStatus(status?: number): number | undefined {\n if (status === undefined || status === null) {\n return undefined;\n }\n\n const statusNum = Number(status);\n\n // Validate status code is a number and within valid HTTP range\n if (Number.isNaN(statusNum) || statusNum < 100 || statusNum > 599) {\n return undefined;\n }\n\n return Math.floor(statusNum);\n }\n\n /**\n * Validates and normalizes the type field\n *\n * @param type - Type value to validate\n * @returns Validated type string or undefined if invalid/empty\n */\n private static validateType(type?: string): string | undefined {\n if (type === undefined || type === null) {\n return undefined;\n }\n\n const typeStr = String(type).trim();\n\n // Return undefined for empty strings\n if (typeStr === '') {\n return undefined;\n }\n\n return typeStr;\n }\n\n /**\n * Validates if an object is a valid ErrorXOptions object.\n * Checks that the object only contains accepted ErrorXOptions fields.\n *\n * @param value - Value to check\n * @returns True if value is a valid ErrorXOptions object\n */\n public static isErrorXOptions(value: unknown): value is ErrorXOptions {\n if (value == null || typeof value !== 'object' || Array.isArray(value)) {\n return false;\n }\n\n // If it's an Error instance, it's not ErrorXOptions\n if (value instanceof Error) {\n return false;\n }\n\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj);\n\n // Empty object is valid ErrorXOptions\n if (keys.length === 0) {\n return true;\n }\n\n // Check if all keys are in the accepted fields\n // If there's any key that's not accepted, it's not ErrorXOptions\n return keys.every((key) => acceptedFields.has(key as ErrorXOptionField));\n }\n\n /**\n * Generates a default error code from the error name.\n * Converts camelCase/PascalCase names to UPPER_SNAKE_CASE format.\n *\n * @param name - Error name to convert\n * @returns Generated error code in UPPER_SNAKE_CASE format\n *\n * @example\n * ```typescript\n * generateDefaultCode('DatabaseError') // 'DATABASE_ERROR'\n * generateDefaultCode('userAuthError') // 'USER_AUTH_ERROR'\n * generateDefaultCode('API Timeout') // 'API_TIMEOUT'\n * ```\n */\n private static generateDefaultCode(name?: string): string {\n if (!name) return 'ERROR';\n\n // Convert camelCase/PascalCase to UPPER_SNAKE_CASE\n return name\n .replace(/([a-z])([A-Z])/g, '$1_$2') // Add underscore between camelCase\n .replace(/\\s+/g, '_') // Replace spaces with underscores\n .replace(/[^a-zA-Z0-9_]/g, '') // Remove special characters\n .toUpperCase();\n }\n\n /**\n * Preserves the original error's stack trace while updating the error message.\n * Combines the new error's message with the original error's stack trace from ErrorXCause.\n *\n * @param cause - The ErrorXCause containing the original stack to preserve\n * @param newError - The new error whose message to use\n * @returns Combined stack trace with new error message and original stack\n */\n private static preserveOriginalStackFromCause(cause: ErrorXCause, newError: Error): string {\n if (!cause.stack) return newError.stack || '';\n\n // Get the new error's first line (error name + message)\n const newErrorFirstLine = `${newError.name}: ${newError.message}`;\n\n // Get original stack lines (skip the first line which is the original error message)\n const originalStackLines = cause.stack.split('\\n');\n const originalStackTrace = originalStackLines.slice(1);\n\n // Combine new error message with original stack trace\n return [newErrorFirstLine, ...originalStackTrace].join('\\n');\n }\n\n /**\n * Cleans the stack trace by removing ErrorX internal method calls.\n * This provides cleaner stack traces that focus on user code.\n *\n * @param stack - Raw stack trace to clean\n * @returns Cleaned stack trace without ErrorX internal calls\n */\n private static cleanStack(stack?: string): string {\n if (!stack) return '';\n\n const config = ErrorX.getConfig();\n const cleanStackConfig = config?.cleanStack ?? true; // Default to true\n\n // If cleanStack is explicitly disabled, return original stack\n if (cleanStackConfig === false) {\n return stack;\n }\n\n const stackLines = stack.split('\\n');\n const cleanedLines: string[] = [];\n\n // Default patterns to remove\n const defaultPatterns = [\n 'new ErrorX',\n 'ErrorX.constructor',\n 'ErrorX.from',\n 'error-x/dist/',\n 'error-x/src/error.ts',\n ];\n\n // Use custom patterns if provided, otherwise use defaults\n const patterns = Array.isArray(cleanStackConfig) ? cleanStackConfig : defaultPatterns;\n\n for (const line of stackLines) {\n // Skip lines that match any of the patterns\n const shouldSkip = patterns.some((pattern) => line.includes(pattern));\n if (shouldSkip) {\n continue;\n }\n cleanedLines.push(line);\n }\n\n return cleanedLines.join('\\n');\n }\n\n /**\n * Processes an error's stack trace to trim it after a specified delimiter.\n * Useful for removing irrelevant stack frames before a specific function.\n *\n * @param error - Error whose stack to process\n * @param delimiter - String to search for in stack lines\n * @returns Processed stack trace starting after the delimiter\n *\n * @example\n * ```typescript\n * const processed = ErrorX.processErrorStack(error, 'my-app-entry')\n * // Returns stack trace starting after the line containing 'my-app-entry'\n * ```\n */\n private static processErrorStack(error: Error, delimiter: string): string {\n let stack = error.stack ?? '';\n const stackLines = stack.split('\\n');\n\n // Find the index of the first line containing the delimiter\n const delimiterIndex = stackLines.findIndex((line) => line.includes(delimiter));\n\n // If the delimiter is found, return all lines after it\n if (delimiterIndex !== -1) {\n stack = stackLines.slice(delimiterIndex + 1).join('\\n');\n }\n return stack;\n }\n\n /**\n * Creates a new ErrorX instance with additional metadata merged with existing metadata.\n * The original error properties are preserved while extending the metadata.\n *\n * @param additionalMetadata - Additional metadata to merge with existing metadata\n * @returns New ErrorX instance with merged metadata\n *\n * @example\n * ```typescript\n * const error = new ErrorX({\n * message: 'API request failed',\n * metadata: { endpoint: '/users' }\n * })\n *\n * const enrichedError = error.withMetadata({\n * retryCount: 3,\n * userId: 123\n * })\n * // Result: metadata = { endpoint: '/users', retryCount: 3, userId: 123 }\n * ```\n */\n public withMetadata(additionalMetadata: Partial<TMetadata>): ErrorX<TMetadata> {\n const options: ErrorXOptions<TMetadata> = {\n message: this.message,\n name: this.name,\n code: this.code,\n uiMessage: this.uiMessage,\n cause: this.cause,\n metadata: { ...(this.metadata ?? {}), ...additionalMetadata } as TMetadata,\n httpStatus: this.httpStatus,\n type: this.type,\n sourceUrl: this.sourceUrl,\n docsUrl: this.docsUrl,\n source: this.source,\n };\n const newError = new ErrorX<TMetadata>(options);\n\n // Preserve the original stack trace and timestamp\n if (this.stack) {\n newError.stack = this.stack;\n }\n newError.timestamp = this.timestamp;\n return newError;\n }\n\n /**\n * Type guard that checks if a value is an ErrorX instance.\n *\n * @param value - Value to check\n * @returns True if value is an ErrorX instance, false otherwise\n *\n * @example\n * ```typescript\n * try {\n * // some operation\n * } catch (error) {\n * if (ErrorX.isErrorX(error)) {\n * // TypeScript knows error is ErrorX\n * console.log(error.code, error.metadata)\n * }\n * }\n * ```\n */\n public static isErrorX<TMetadata extends ErrorXMetadata = ErrorXMetadata>(\n value: unknown\n ): value is ErrorX<TMetadata> {\n return value instanceof ErrorX;\n }\n\n /**\n * Converts unknown input into ErrorXOptions with intelligent property extraction.\n * Handles strings, regular Error objects, API response objects, and unknown values.\n * This is a private helper method used by both the constructor and toErrorX.\n *\n * @param error - Value to convert to ErrorXOptions\n * @returns ErrorXOptions object with extracted properties\n * @internal\n */\n private static convertUnknownToOptions(error: unknown): ErrorXOptions {\n let name = '';\n let message = '';\n let code = '';\n let uiMessage = '';\n let cause: unknown;\n let metadata: ErrorXMetadata = {};\n let httpStatus: number | undefined;\n let type: string | undefined;\n let url: string | undefined;\n let href: string | undefined;\n let source: string | undefined;\n\n if (error) {\n if (typeof error === 'string') {\n message = error;\n metadata = { originalError: error };\n } else if (error instanceof Error) {\n name = error.name;\n message = error.message;\n cause = error.cause;\n } else if (typeof error === 'object') {\n // Extract name from various properties\n if ('name' in error && error.name) name = String(error.name);\n else if ('title' in error && error.title) name = String(error.title);\n\n // Extract message from various properties\n if ('message' in error && error.message) message = String(error.message);\n else if ('details' in error && error.details) message = String(error.details);\n else if ('text' in error && error.text) message = String(error.text);\n else if ('info' in error && error.info) message = String(error.info);\n else if ('statusText' in error && error.statusText) message = String(error.statusText);\n else if ('error' in error && error.error) message = String(error.error);\n else if ('errorMessage' in error && error.errorMessage)\n message = String(error.errorMessage);\n\n // Extract code\n if ('code' in error && error.code) code = String(error.code);\n\n // Extract UI message\n if ('uiMessage' in error && error.uiMessage) uiMessage = String(error.uiMessage);\n else if ('userMessage' in error && error.userMessage) uiMessage = String(error.userMessage);\n\n let _httpStatus: unknown;\n // Extract HTTP status\n if ('httpStatus' in error) {\n _httpStatus = error.httpStatus;\n } else if ('status' in error) {\n _httpStatus = error.status;\n } else if ('statusCode' in error) {\n _httpStatus = error.statusCode;\n }\n if (_httpStatus !== undefined && _httpStatus !== null) {\n const num = typeof _httpStatus === 'number' ? _httpStatus : Number(_httpStatus);\n httpStatus = ErrorX.validateHttpStatus(num);\n }\n\n // Extract type\n if ('type' in error && error.type) {\n type = ErrorX.validateType(String(error.type));\n }\n\n // Extract sourceUrl\n if ('sourceUrl' in error && error.sourceUrl) {\n url = String(error.sourceUrl);\n } else if ('url' in error && error.url) {\n url = String(error.url);\n }\n\n // Extract docsUrl\n if ('docsUrl' in error && error.docsUrl) {\n href = String(error.docsUrl);\n } else if ('href' in error && error.href) {\n href = String(error.href);\n } else if ('documentationUrl' in error && error.documentationUrl) {\n href = String(error.documentationUrl);\n }\n\n // Extract source\n if ('source' in error && error.source) {\n source = String(error.source);\n } else if ('service' in error && error.service) {\n source = String(error.service);\n } else if ('component' in error && error.component) {\n source = String(error.component);\n }\n\n // Store original object as metadata if it has additional properties\n metadata = { originalError: error };\n }\n }\n\n const options: ErrorXOptions = {\n message: message || 'Unknown error occurred',\n };\n\n if (name) options.name = name;\n if (code) options.code = code;\n if (uiMessage) options.uiMessage = uiMessage;\n if (cause) options.cause = cause;\n if (Object.keys(metadata).length > 0) options.metadata = metadata;\n if (httpStatus) options.httpStatus = httpStatus;\n if (type) options.type = type;\n if (url) options.sourceUrl = url;\n if (href) options.docsUrl = href;\n if (source) options.source = source;\n\n return options;\n }\n\n /**\n * Converts unknown input into an ErrorX instance with intelligent property extraction.\n * Handles strings, regular Error objects, API response objects, and unknown values.\n *\n * @param error - Value to convert to ErrorX\n * @returns ErrorX instance with extracted properties\n *\n * @example\n * ```typescript\n * // Convert string error\n * const error1 = ErrorX.from('Something went wrong')\n *\n * // Convert regular Error\n * const error2 = ErrorX.from(new Error('Database failed'))\n *\n * // Convert API response object\n * const apiError = {\n * message: 'User not found',\n * code: 'USER_404',\n * statusText: 'Not Found'\n * }\n * const error3 = ErrorX.from(apiError)\n * ```\n */\n public static from<TMetadata extends ErrorXMetadata = ErrorXMetadata>(\n error: ErrorX<TMetadata>\n ): ErrorX<TMetadata>;\n public static from(error: Error): ErrorX;\n public static from(error: string): ErrorX;\n public static from(error: unknown): ErrorX;\n public static from(error: unknown): ErrorX {\n if (error instanceof ErrorX) return error;\n\n const options = ErrorX.convertUnknownToOptions(error);\n return new ErrorX(options);\n }\n\n /**\n * Creates a new ErrorX instance with cleaned stack trace using the specified delimiter.\n * Returns the same instance if no delimiter is provided or no stack is available.\n *\n * @param delimiter - Optional string to search for in stack lines\n * @returns New ErrorX instance with cleaned stack trace, or the same instance if no cleaning needed\n *\n * @example\n * ```typescript\n * const error = new ErrorX({ message: 'Database error' })\n * const cleanedError = error.cleanStackTrace('database-layer')\n * // Returns new ErrorX with stack trace starting after 'database-layer'\n * ```\n */\n public cleanStackTrace(delimiter?: string): ErrorX<TMetadata> {\n if (delimiter && this.stack) {\n const options: ErrorXOptions = {\n message: this.message,\n name: this.name,\n code: this.code,\n uiMessage: this.uiMessage,\n cause: this.cause,\n httpStatus: this.httpStatus,\n type: this.type,\n sourceUrl: this.sourceUrl,\n docsUrl: this.docsUrl,\n source: this.source,\n };\n if (this.metadata !== undefined) {\n options.metadata = this.metadata;\n }\n const newError = new ErrorX<TMetadata>(options as ErrorXOptions<TMetadata>);\n newError.stack = ErrorX.processErrorStack(this, delimiter);\n return newError;\n }\n return this;\n }\n\n /**\n * Converts the ErrorX instance to a detailed string representation.\n * Includes error name, message, code, timestamp, metadata, and stack trace.\n *\n * @returns Formatted string representation of the error\n *\n * @example\n * ```typescript\n * const error = new ErrorX({\n * message: 'Database connection failed',\n * name: 'DatabaseError',\n * code: 'DB_CONN_FAILED',\n * metadata: { host: 'localhost', port: 5432 }\n * })\n *\n * console.log(error.toString())\n * // Output: \"DatabaseError: Database connection failed. [DB_CONN_FAILED] (2024-01-15T10:30:45.123Z) metadata: {...}\"\n * ```\n */\n public toString(): string {\n const parts = [];\n\n // Add name and message\n parts.push(`${this.name}: ${this.message}`);\n\n // Add code if different from default\n if (this.code && this.code !== 'ERROR') {\n parts.push(`[${this.code}]`);\n }\n\n // Add timestamp\n parts.push(`(${this.timestamp.toISOString()})`);\n\n // Add metadata if present\n if (this.metadata && Object.keys(this.metadata).length > 0) {\n const metadataStr = safeStringify(this.metadata);\n parts.push(`metadata: ${metadataStr}`);\n }\n\n let result = parts.join(' ');\n\n // Add stack trace if available\n if (this.stack) {\n result += `\\n${this.stack}`;\n }\n\n return result;\n }\n\n /**\n * Serializes the ErrorX instance to a JSON-compatible object.\n * Recursively serializes the error chain and handles ErrorX or regular Error causes.\n *\n * @returns Serializable object representation of the error\n *\n * @example\n * ```typescript\n * const error = new ErrorX({\n * message: 'API request failed',\n * code: 'API_ERROR',\n * metadata: { endpoint: '/users', status: 500 }\n * })\n *\n * const serialized = error.toJSON()\n * // Can be safely passed to JSON.stringify() or sent over network\n * ```\n */\n public toJSON(): ErrorXSerialized {\n // Handle metadata serialization with circular reference protection\n // safeStringify already handles circular references, but we need to\n // return a plain object (not a string) for toJSON()\n // Using a try-catch to fallback to safe serialization if needed\n let safeMetadata: ErrorXMetadata | undefined;\n if (this.metadata) {\n // Always use safeStringify to handle circular references and ensure a plain object\n safeMetadata = JSON.parse(safeStringify(this.metadata));\n }\n\n const serialized: ErrorXSerialized = {\n name: this.name,\n message: this.message,\n code: this.code,\n uiMessage: this.uiMessage,\n metadata: safeMetadata,\n timestamp: this.timestamp.toISOString(),\n };\n\n // Include httpStatus if present\n if (this.httpStatus !== undefined) {\n serialized.httpStatus = this.httpStatus;\n }\n\n // Include type if present\n if (this.type !== undefined) {\n serialized.type = this.type;\n }\n\n // Include url if present\n if (this.sourceUrl !== undefined) {\n serialized.sourceUrl = this.sourceUrl;\n }\n\n // Include href if present\n if (this.docsUrl !== undefined) {\n serialized.docsUrl = this.docsUrl;\n }\n\n // Include source if present\n if (this.source !== undefined) {\n serialized.source = this.source;\n }\n\n // Include stack if available\n if (this.stack) {\n serialized.stack = this.stack;\n }\n\n // Include cause if present (already in ErrorXCause format)\n if (this.cause) {\n serialized.cause = this.cause;\n }\n\n return serialized;\n }\n\n /**\n * Deserializes a JSON object back into an ErrorX instance.\n * Recursively reconstructs the error chain and restores all properties.\n *\n * @param serialized - Serialized error object to deserialize\n * @returns Reconstructed ErrorX instance with restored properties\n *\n * @example\n * ```typescript\n * const serializedError = {\n * name: 'DatabaseError',\n * message: 'Connection failed.',\n * code: 'DB_CONN_FAILED',\n * uiMessage: 'Database is temporarily unavailable',\n * metadata: { host: 'localhost' },\n * timestamp: '2024-01-15T10:30:45.123Z'\n * }\n *\n * const error = ErrorX.fromJSON(serializedError)\n * // Fully restored ErrorX instance with all properties\n * ```\n */\n public static fromJSON<TMetadata extends ErrorXMetadata = ErrorXMetadata>(\n serialized: ErrorXSerialized\n ): ErrorX<TMetadata> {\n const options: ErrorXOptions = {\n message: serialized.message,\n name: serialized.name,\n code: serialized.code,\n uiMessage: serialized.uiMessage,\n httpStatus: serialized.httpStatus,\n type: serialized.type,\n sourceUrl: serialized.sourceUrl,\n docsUrl: serialized.docsUrl,\n source: serialized.source,\n cause: serialized.cause,\n };\n if (serialized.metadata !== undefined) {\n options.metadata = serialized.metadata;\n }\n\n const error = new ErrorX<TMetadata>(options as ErrorXOptions<TMetadata>);\n\n // Restore stack and timestamp\n if (serialized.stack) {\n error.stack = serialized.stack;\n }\n // Properties are now mutable, so we can set directly\n error.timestamp = new Date(serialized.timestamp);\n\n return error;\n }\n}\n","import type { ErrorXOptions } from './types.js';\n\n/**\n * HTTP error presets for common HTTP status codes.\n *\n * These presets provide pre-configured error options for standard HTTP error responses,\n * including appropriate status codes, error codes, names, messages (sentence case), and user-friendly UI messages.\n *\n * ## Usage Patterns\n *\n * ### 1. Use Preset Directly\n * Create an error with all preset values:\n * ```typescript\n * throw new ErrorX(http.notFound)\n * // Result: 404 error with message \"Not found.\", code, name, uiMessage, and type\n * ```\n *\n * ### 2. Override Specific Fields\n * Customize the error while keeping other preset values:\n * ```typescript\n * throw new ErrorX({\n * ...http.notFound,\n * message: 'User not found',\n * metadata: { userId: 123 }\n * })\n * // Result: 404 error with custom message but keeps httpStatus, code, name, uiMessage, type\n * ```\n *\n * ### 3. Add Metadata\n * Enhance presets with additional context:\n * ```typescript\n * throw new ErrorX({\n * ...http.unauthorized,\n * metadata: { attemptedAction: 'viewProfile', userId: 456 }\n * })\n * ```\n *\n * ### 4. Add Error Cause\n * Chain errors by adding a cause:\n * ```typescript\n * try {\n * // some operation\n * } catch (originalError) {\n * throw new ErrorX({\n * ...http.internalServerError,\n * cause: originalError,\n * metadata: { operation: 'database-query' }\n * })\n * }\n * ```\n *\n * ## Common HTTP Presets\n *\n * ### 4xx Client Errors\n * - `badRequest` (400) - Invalid request data\n * - `unauthorized` (401) - Authentication required\n * - `forbidden` (403) - Insufficient permissions\n * - `notFound` (404) - Resource not found\n * - `methodNotAllowed` (405) - HTTP method not allowed\n * - `conflict` (409) - Resource conflict\n * - `unprocessableEntity` (422) - Validation failed\n * - `tooManyRequests` (429) - Rate limit exceeded\n *\n * ### 5xx Server Errors\n * - `internalServerError` (500) - Unexpected server error\n * - `notImplemented` (501) - Feature not implemented\n * - `badGateway` (502) - Upstream server error\n * - `serviceUnavailable` (503) - Service temporarily down\n * - `gatewayTimeout` (504) - Upstream timeout\n *\n * @example\n * ```typescript\n * // API endpoint example\n * app.get('/users/:id', async (req, res) => {\n * const user = await db.users.findById(req.params.id)\n *\n * if (!user) {\n * throw new ErrorX({\n * ...http.notFound,\n * message: 'User not found',\n * metadata: { userId: req.params.id }\n * })\n * }\n *\n * res.json(user)\n * })\n *\n * // Authentication middleware example\n * const requireAuth = (req, res, next) => {\n * if (!req.user) {\n * throw new ErrorX(http.unauthorized)\n * }\n * next()\n * }\n *\n * // Rate limiting example\n * if (isRateLimited(req.ip)) {\n * throw new ErrorX({\n * ...http.tooManyRequests,\n * metadata: {\n * ip: req.ip,\n * retryAfter: 60\n * }\n * })\n * }\n * ```\n *\n * @public\n */\nexport const http = {\n // 4xx Client Errors\n badRequest: {\n httpStatus: 400,\n code: 'BAD_REQUEST',\n name: 'Bad Request Error',\n message: 'Bad request.',\n uiMessage: 'The request could not be processed. Please check your input and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n unauthorized: {\n httpStatus: 401,\n code: 'UNAUTHORIZED',\n name: 'Unauthorized Error',\n message: 'Unauthorized.',\n uiMessage: 'Authentication required. Please log in to continue.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n paymentRequired: {\n httpStatus: 402,\n code: 'PAYMENT_REQUIRED',\n name: 'Payment Required Error',\n message: 'Payment required.',\n uiMessage: 'Payment is required to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n forbidden: {\n httpStatus: 403,\n code: 'FORBIDDEN',\n name: 'Forbidden Error',\n message: 'Forbidden.',\n uiMessage: 'You do not have permission to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n notFound: {\n httpStatus: 404,\n code: 'NOT_FOUND',\n name: 'Not Found Error',\n message: 'Not found.',\n uiMessage: 'The requested resource could not be found.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n methodNotAllowed: {\n httpStatus: 405,\n code: 'METHOD_NOT_ALLOWED',\n name: 'Method Not Allowed Error',\n message: 'Method not allowed.',\n uiMessage: 'This action is not allowed for the requested resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n notAcceptable: {\n httpStatus: 406,\n code: 'NOT_ACCEPTABLE',\n name: 'Not Acceptable Error',\n message: 'Not acceptable.',\n uiMessage: 'The requested format is not supported.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n proxyAuthenticationRequired: {\n httpStatus: 407,\n code: 'PROXY_AUTHENTICATION_REQUIRED',\n name: 'Proxy Authentication Required Error',\n message: 'Proxy authentication required.',\n uiMessage: 'Proxy authentication is required to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n requestTimeout: {\n httpStatus: 408,\n code: 'REQUEST_TIMEOUT',\n name: 'Request Timeout Error',\n message: 'Request timeout.',\n uiMessage: 'The request took too long to complete. Please try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n conflict: {\n httpStatus: 409,\n code: 'CONFLICT',\n name: 'Conflict Error',\n message: 'Conflict.',\n uiMessage: 'The request conflicts with the current state. Please refresh and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n gone: {\n httpStatus: 410,\n code: 'GONE',\n name: 'Gone Error',\n message: 'Gone.',\n uiMessage: 'This resource is no longer available.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n lengthRequired: {\n httpStatus: 411,\n code: 'LENGTH_REQUIRED',\n name: 'Length Required Error',\n message: 'Length required.',\n uiMessage: 'The request is missing required length information.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n preconditionFailed: {\n httpStatus: 412,\n code: 'PRECONDITION_FAILED',\n name: 'Precondition Failed Error',\n message: 'Precondition failed.',\n uiMessage: 'A required condition was not met. Please try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n payloadTooLarge: {\n httpStatus: 413,\n code: 'PAYLOAD_TOO_LARGE',\n name: 'Payload Too Large Error',\n message: 'Payload too large.',\n uiMessage: 'The request is too large. Please reduce the size and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n uriTooLong: {\n httpStatus: 414,\n code: 'URI_TOO_LONG',\n name: 'URI Too Long Error',\n message: 'URI too long.',\n uiMessage: 'The request URL is too long.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n unsupportedMediaType: {\n httpStatus: 415,\n code: 'UNSUPPORTED_MEDIA_TYPE',\n name: 'Unsupported Media Type Error',\n message: 'Unsupported media type.',\n uiMessage: 'The file type is not supported.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n rangeNotSatisfiable: {\n httpStatus: 416,\n code: 'RANGE_NOT_SATISFIABLE',\n name: 'Range Not Satisfiable Error',\n message: 'Range not satisfiable.',\n uiMessage: 'The requested range cannot be satisfied.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n expectationFailed: {\n httpStatus: 417,\n code: 'EXPECTATION_FAILED',\n name: 'Expectation Failed Error',\n message: 'Expectation failed.',\n uiMessage: 'The server cannot meet the requirements of the request.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n imATeapot: {\n httpStatus: 418,\n code: 'IM_A_TEAPOT',\n name: 'Im A Teapot Error',\n message: \"I'm a teapot.\",\n uiMessage: \"I'm a teapot and cannot brew coffee.\",\n type: 'http',\n } satisfies ErrorXOptions,\n\n unprocessableEntity: {\n httpStatus: 422,\n code: 'UNPROCESSABLE_ENTITY',\n name: 'Unprocessable Entity Error',\n message: 'Unprocessable entity.',\n uiMessage: 'The request contains invalid data. Please check your input.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n locked: {\n httpStatus: 423,\n code: 'LOCKED',\n name: 'Locked Error',\n message: 'Locked.',\n uiMessage: 'This resource is locked and cannot be modified.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n failedDependency: {\n httpStatus: 424,\n code: 'FAILED_DEPENDENCY',\n name: 'Failed Dependency Error',\n message: 'Failed dependency.',\n uiMessage: 'The request failed due to a dependency error.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n tooEarly: {\n httpStatus: 425,\n code: 'TOO_EARLY',\n name: 'Too Early Error',\n message: 'Too early.',\n uiMessage: 'The request was sent too early. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n upgradeRequired: {\n httpStatus: 426,\n code: 'UPGRADE_REQUIRED',\n name: 'Upgrade Required Error',\n message: 'Upgrade required.',\n uiMessage: 'Please upgrade to continue using this service.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n preconditionRequired: {\n httpStatus: 428,\n code: 'PRECONDITION_REQUIRED',\n name: 'Precondition Required Error',\n message: 'Precondition required.',\n uiMessage: 'Required conditions are missing from the request.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n tooManyRequests: {\n httpStatus: 429,\n code: 'TOO_MANY_REQUESTS',\n name: 'Too Many Requests Error',\n message: 'Too many requests.',\n uiMessage: 'You have made too many requests. Please wait and try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n requestHeaderFieldsTooLarge: {\n httpStatus: 431,\n code: 'REQUEST_HEADER_FIELDS_TOO_LARGE',\n name: 'Request Header Fields Too Large Error',\n message: 'Request header fields too large.',\n uiMessage: 'The request headers are too large.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n unavailableForLegalReasons: {\n httpStatus: 451,\n code: 'UNAVAILABLE_FOR_LEGAL_REASONS',\n name: 'Unavailable For Legal Reasons Error',\n message: 'Unavailable for legal reasons.',\n uiMessage: 'This content is unavailable for legal reasons.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n // 5xx Server Errors\n internalServerError: {\n httpStatus: 500,\n code: 'INTERNAL_SERVER_ERROR',\n name: 'Internal Server Error',\n message: 'Internal server error.',\n uiMessage: 'An unexpected error occurred. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n notImplemented: {\n httpStatus: 501,\n code: 'NOT_IMPLEMENTED',\n name: 'Not Implemented Error',\n message: 'Not implemented.',\n uiMessage: 'This feature is not yet available.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n badGateway: {\n httpStatus: 502,\n code: 'BAD_GATEWAY',\n name: 'Bad Gateway Error',\n message: 'Bad gateway.',\n uiMessage: 'Unable to connect to the server. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n serviceUnavailable: {\n httpStatus: 503,\n code: 'SERVICE_UNAVAILABLE',\n name: 'Service Unavailable Error',\n message: 'Service unavailable.',\n uiMessage: 'The service is temporarily unavailable. Please try again later.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n gatewayTimeout: {\n httpStatus: 504,\n code: 'GATEWAY_TIMEOUT',\n name: 'Gateway Timeout Error',\n message: 'Gateway timeout.',\n uiMessage: 'The server took too long to respond. Please try again.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n httpVersionNotSupported: {\n httpStatus: 505,\n code: 'HTTP_VERSION_NOT_SUPPORTED',\n name: 'HTTP Version Not Supported Error',\n message: 'HTTP version not supported.',\n uiMessage: 'Your browser version is not supported.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n variantAlsoNegotiates: {\n httpStatus: 506,\n code: 'VARIANT_ALSO_NEGOTIATES',\n name: 'Variant Also Negotiates Error',\n message: 'Variant also negotiates.',\n uiMessage: 'The server has an internal configuration error.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n insufficientStorage: {\n httpStatus: 507,\n code: 'INSUFFICIENT_STORAGE',\n name: 'Insufficient Storage Error',\n message: 'Insufficient storage.',\n uiMessage: 'The server has insufficient storage to complete the request.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n loopDetected: {\n httpStatus: 508,\n code: 'LOOP_DETECTED',\n name: 'Loop Detected Error',\n message: 'Loop detected.',\n uiMessage: 'The server detected an infinite loop.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n notExtended: {\n httpStatus: 510,\n code: 'NOT_EXTENDED',\n name: 'Not Extended Error',\n message: 'Not extended.',\n uiMessage: 'Additional extensions are required.',\n type: 'http',\n } satisfies ErrorXOptions,\n\n networkAuthenticationRequired: {\n httpStatus: 511,\n code: 'NETWORK_AUTHENTICATION_REQUIRED',\n name: 'Network Authentication Required Error',\n message: 'Network authentication required.',\n uiMessage: 'Network authentication is required to access this resource.',\n type: 'http',\n } satisfies ErrorXOptions,\n} as const;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bombillazo/error-x",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "A simple and consistent error handling library for TypeScript applications. Provides type-safe error handling with great DX, solving common pain points like unknown error types, lost stack traces, async error handling, and error serialization. Isomorphic and framework-agnostic.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",