Update error codes when process exiting the gemini cli (#13728)

This commit is contained in:
Megha Bansal
2025-11-26 08:13:21 +05:30
committed by GitHub
parent d2a6cff4df
commit d97bbd5324
12 changed files with 307 additions and 192 deletions

View File

@@ -56,6 +56,7 @@ import {
enterAlternateScreen,
disableLineWrapping,
shouldEnterAlternateScreen,
ExitCodes,
} from '@google/gemini-cli-core';
import {
initializeApp,
@@ -310,7 +311,7 @@ export async function main() {
'Error: The --prompt-interactive flag cannot be used when input is piped from stdin.\n',
);
await runExitCleanup();
process.exit(1);
process.exit(ExitCodes.FATAL_INPUT_ERROR);
}
const isDebugMode = cliConfig.isDebugMode(argv);
@@ -396,7 +397,7 @@ export async function main() {
} catch (err) {
debugLogger.error('Error authenticating:', err);
await runExitCleanup();
process.exit(1);
process.exit(ExitCodes.FATAL_AUTHENTICATION_ERROR);
}
}
let stdinData = '';
@@ -433,7 +434,7 @@ export async function main() {
start_sandbox(sandboxConfig, memoryArgs, partialConfig, sandboxArgs),
);
await runExitCleanup();
process.exit(0);
process.exit(ExitCodes.SUCCESS);
} else {
// Relaunch app so we always have a child process that can be internally
// restarted if needed.
@@ -464,14 +465,14 @@ export async function main() {
debugLogger.log(`- ${extension.name}`);
}
await runExitCleanup();
process.exit(0);
process.exit(ExitCodes.SUCCESS);
}
// Handle --list-sessions flag
if (config.getListSessions()) {
await listSessions(config);
await runExitCleanup();
process.exit(0);
process.exit(ExitCodes.SUCCESS);
}
// Handle --delete-session flag
@@ -479,7 +480,7 @@ export async function main() {
if (sessionToDelete) {
await deleteSession(config, sessionToDelete);
await runExitCleanup();
process.exit(0);
process.exit(ExitCodes.SUCCESS);
}
const wasRaw = process.stdin.isRaw;
@@ -551,7 +552,7 @@ export async function main() {
`Error resuming session: ${error instanceof Error ? error.message : 'Unknown error'}`,
);
await runExitCleanup();
process.exit(1);
process.exit(ExitCodes.FATAL_INPUT_ERROR);
}
}
@@ -583,7 +584,7 @@ export async function main() {
`No input provided via stdin. Input can be provided by piping data into gemini or using the --prompt option.`,
);
await runExitCleanup();
process.exit(1);
process.exit(ExitCodes.FATAL_INPUT_ERROR);
}
const prompt_id = Math.random().toString(16).slice(2);
@@ -623,7 +624,7 @@ export async function main() {
});
// Call cleanup before process.exit, which causes cleanup to not run
await runExitCleanup();
process.exit(0);
process.exit(ExitCodes.SUCCESS);
}
}