fix: add friendly error messages for failed binary spawning

Added helpful error messages with cause preservation when spawning codex, gemini, or other CLI tools fails because the binary is not found in PATH. This follows the existing error handling pattern from claudeLocal.ts.
This commit is contained in:
weishu
2025-12-23 20:20:51 +08:00
parent bf7ae6fdd6
commit 706814653e
2 changed files with 7 additions and 2 deletions
@@ -65,7 +65,11 @@ export class AcpStdioTransport {
this.process.on('error', (error) => {
logger.debug('[ACP] Process error', error);
this.rejectAllPending(error instanceof Error ? error : new Error(String(error)));
const message = error instanceof Error ? error.message : String(error);
this.rejectAllPending(new Error(
`Failed to spawn ${options.command}: ${message}. Is it installed and on PATH?`,
{ cause: error }
));
});
}
+2 -1
View File
@@ -95,7 +95,8 @@ export async function codexLocal(opts: {
child.on('error', (error) => {
cleanupAbortHandler();
reject(error);
const message = error instanceof Error ? error.message : String(error);
reject(new Error(`Failed to spawn codex: ${message}. Is Codex CLI installed and on PATH?`, { cause: error }));
});
child.on('exit', (code, signal) => {