/** * Error Handler Middleware * * Provides consistent error handling and formatting across all CLI commands. * Supports debug mode for detailed stack traces. */ /** * Standard exit codes */ export declare const EXIT_CODES: { /** Successful execution */ readonly SUCCESS: 0; /** General error */ readonly ERROR: 1; /** Authentication error */ readonly AUTH_ERROR: 2; /** Configuration error */ readonly CONFIG_ERROR: 3; /** Network/API error */ readonly NETWORK_ERROR: 4; /** Not found error */ readonly NOT_FOUND: 5; /** Validation error */ readonly VALIDATION_ERROR: 6; }; export type ExitCode = typeof EXIT_CODES[keyof typeof EXIT_CODES]; /** * Custom error class for CLI errors with exit codes */ export declare class CliError extends Error { readonly exitCode: ExitCode; readonly hint?: string | undefined; constructor(message: string, exitCode?: ExitCode, hint?: string | undefined); } /** * Authentication error */ export declare class AuthError extends CliError { constructor(message?: string); } /** * Configuration error */ export declare class ConfigError extends CliError { constructor(message: string, hint?: string); } /** * Network/API error */ export declare class NetworkError extends CliError { constructor(message: string, hint?: string); } /** * Not found error */ export declare class NotFoundError extends CliError { constructor(resource: string, identifier?: string); } /** * Validation error */ export declare class ValidationError extends CliError { constructor(message: string, hint?: string); } /** * Check if debug mode is enabled */ export declare function isDebugMode(): boolean; /** * Format error for display * * @param error - Error to format * @returns Formatted error string */ export declare function formatError(error: unknown): string; /** * Handle error and exit process * * @param error - Error to handle */ export declare function handleError(error: unknown): never; /** * Wrap an async function with error handling * * Use this to wrap command action handlers for automatic error handling. * * @param fn - Async function to wrap * @returns Wrapped function that handles errors * * @example * ```typescript * program * .command('status') * .action(withErrorHandler(async () => { * // If this throws, error is caught and formatted * const data = await api.getStatus(); * })); * ``` */ export declare function withErrorHandler(fn: (...args: T) => Promise): (...args: T) => Promise; /** * Wrap a sync function with error handling * * @param fn - Sync function to wrap * @returns Wrapped function that handles errors */ export declare function withErrorHandlerSync(fn: (...args: T) => R): (...args: T) => void; /** * Log debug information (only in debug mode) * * @param message - Message to log * @param data - Optional data to log */ export declare function debugLog(message: string, data?: unknown): void; /** * Log warning message * * @param message - Warning message */ export declare function warnLog(message: string): void; /** * Log success message * * @param message - Success message */ export declare function successLog(message: string): void; /** * Log info message * * @param message - Info message */ export declare function infoLog(message: string): void; //# sourceMappingURL=error-handler.d.ts.map