UNPKG

browser-debugger-cli

Version:

DevTools telemetry in your terminal. For humans and agents. Direct WebSocket to Chrome's debugging port.

60 lines 1.91 kB
/** * Centralized IPC error-to-exit code mapping. * * Provides a single source of truth for mapping IPC error codes and connection * errors to semantic exit codes. This eliminates scattered, inconsistent error * handling across commands. * * WHY: Different commands had duplicate, inconsistent error-to-exit-code logic. * Some used helper functions, others used string matching. This module provides * consistent, maintainable error handling. */ import { IPCErrorCode } from '../ipc/index.js'; /** * Map IPC error codes to semantic exit codes. * * @param errorCode - IPC error code from daemon response * @returns Semantic exit code for the error * * @example * ```typescript * const exitCode = getExitCodeForIPCError(response.errorCode); * process.exit(exitCode); * ``` */ export declare function getExitCodeForIPCError(errorCode?: IPCErrorCode): number; /** * Map connection error messages to semantic exit codes. * * Handles common socket and connection errors that indicate the daemon * is not running or unreachable. * * @param errorMessage - Error message string to analyze * @returns Semantic exit code for the error * * @example * ```typescript * try { * await connectToDaemon(); * } catch (error) { * const exitCode = getExitCodeForConnectionError(getErrorMessage(error)); * process.exit(exitCode); * } * ``` */ export declare function getExitCodeForConnectionError(errorMessage: string): number; /** * Check if an error message indicates the daemon is not running. * * @param errorMessage - Error message to check * @returns True if the error indicates daemon is not running * * @example * ```typescript * if (isDaemonNotRunningError(errorMessage)) { * console.error('Start a session first with: bdg <url>'); * } * ``` */ export declare function isDaemonNotRunningError(errorMessage: string): boolean; //# sourceMappingURL=errorMapping.d.ts.map