/** * Centralized error handling utilities */ import { Logger } from './logger.js'; import { PhotonError, ValidationError } from '@portel/photon-core'; export { PhotonError, ValidationError }; /** * Standard CLI exit codes following Unix conventions * @see https://tldp.org/LDP/abs/html/exitcodes.html */ export declare const ExitCode: { /** Command completed successfully */ readonly SUCCESS: 0; /** General/unspecified error */ readonly ERROR: 1; /** Invalid command-line argument or usage */ readonly INVALID_ARGUMENT: 2; /** Configuration error (missing or invalid config) */ readonly CONFIG_ERROR: 3; /** File or resource not found */ readonly NOT_FOUND: 4; /** Network or connection error */ readonly NETWORK_ERROR: 5; /** Validation error (input validation failed) */ readonly VALIDATION_ERROR: 6; /** Permission denied */ readonly PERMISSION_DENIED: 13; /** Operation was cancelled by user */ readonly CANCELLED: 130; }; type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode]; /** * Safe error message extraction */ export declare function getErrorMessage(error: unknown): string; /** * Check if error is a Node.js file system error */ export declare function isNodeError(error: unknown, code?: string): error is NodeJS.ErrnoException; /** * Convert unknown error to PhotonError */ export declare function wrapError(error: unknown, context?: string, suggestion?: string): PhotonError; /** * Centralized error handler for CLI commands */ export declare function handleError(error: unknown, options?: { logger?: Logger; exitOnError?: boolean; exitCode?: ExitCodeType; showStack?: boolean; }): never | void; /** * Print error to stderr and exit with appropriate code. * * Options: * - suggestion: short tip (what to do next) * - searchedIn: path that was searched (for not-found cases) * - docsAnchor: TROUBLESHOOTING.md anchor (e.g. 'mcp-not-found-in-marketplace'). * Appended as 'Docs: #' to give users a place to read more. * - docsUrl: full override when the docs live elsewhere. */ export declare function exitWithError(message: string, options?: { exitCode?: ExitCodeType; suggestion?: string; searchedIn?: string; docsAnchor?: string; docsUrl?: string; logger?: Logger; }): never; /** * Format a tool call error into a structured message for AI clients. * Used by both STDIO and SSE transports to ensure consistent error reporting. */ export declare function formatToolError(toolName: string, error: unknown): { text: string; errorType: string; retryable: boolean; }; //# sourceMappingURL=error-handler.d.ts.map