/** * SpecWeave Error Hierarchy * * Centralized error types for the SpecWeave framework. * All custom errors extend SpecWeaveError for consistent error handling. * * @module core/errors */ /** * Error codes for categorization */ export declare enum ErrorCode { CONFIG_NOT_FOUND = 1001, CONFIG_INVALID = 1002, CONFIG_PARSE_ERROR = 1003, SYNC_FAILED = 2001, SYNC_CONFLICT = 2002, SYNC_RATE_LIMITED = 2003, SYNC_PERMISSION_DENIED = 2004, SYNC_NETWORK_ERROR = 2005, IMPORT_FAILED = 3001, IMPORT_PARSE_ERROR = 3002, IMPORT_INVALID_FORMAT = 3003, IMPORT_DUPLICATE = 3004, VALIDATION_FAILED = 4001, VALIDATION_SCHEMA_ERROR = 4002, VALIDATION_REQUIRED_FIELD = 4003, INCREMENT_NOT_FOUND = 5001, INCREMENT_INVALID_STATUS = 5002, INCREMENT_LOCKED = 5003, INCREMENT_METADATA_ERROR = 5004, PLUGIN_NOT_FOUND = 6001, PLUGIN_LOAD_ERROR = 6002, PLUGIN_EXECUTION_ERROR = 6003, INTEGRATION_AUTH_ERROR = 7001, INTEGRATION_API_ERROR = 7002, INTEGRATION_TIMEOUT = 7003, FS_READ_ERROR = 8001, FS_WRITE_ERROR = 8002, FS_NOT_FOUND = 8003, FS_PERMISSION_DENIED = 8004, UNKNOWN = 9999 } /** * Base error for all SpecWeave errors * * @example * ```typescript * throw new SpecWeaveError('Something went wrong', { * code: ErrorCode.UNKNOWN, * context: { incrementId: '0001' } * }); * ``` */ export declare class SpecWeaveError extends Error { readonly code: ErrorCode; readonly context?: Record; readonly timestamp: Date; readonly originalCause?: Error; constructor(message: string, options?: { code?: ErrorCode; context?: Record; cause?: Error; }); /** * Format error for logging */ toLogString(): string; /** * Serialize error for API responses */ toJSON(): Record; } /** * Validation-related errors */ export declare class ValidationError extends SpecWeaveError { readonly field?: string; constructor(message: string, options?: { code?: ErrorCode; context?: Record; cause?: Error; field?: string; }); } /** * Type guard to check if an error is a SpecWeaveError */ export declare function isSpecWeaveError(error: unknown): error is SpecWeaveError; /** * Wrap an unknown error in a SpecWeaveError */ export declare function wrapError(error: unknown, message?: string, code?: ErrorCode): SpecWeaveError; //# sourceMappingURL=index.d.ts.map