mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
fix(cli): re-throw errors in non-interactive mode (#11849)
This commit is contained in:
@@ -71,6 +71,7 @@ export async function runNonInteractive(
|
||||
? new StreamJsonFormatter()
|
||||
: null;
|
||||
|
||||
let errorToHandle: unknown | undefined;
|
||||
try {
|
||||
consolePatcher.patch();
|
||||
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
||||
@@ -213,6 +214,8 @@ export async function runNonInteractive(
|
||||
message: 'Maximum session turns exceeded',
|
||||
});
|
||||
}
|
||||
} else if (event.type === GeminiEventType.Error) {
|
||||
throw event.value.error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +305,7 @@ export async function runNonInteractive(
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
handleError(error, config);
|
||||
errorToHandle = error;
|
||||
} finally {
|
||||
consolePatcher.cleanup();
|
||||
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
||||
@@ -310,5 +313,9 @@ export async function runNonInteractive(
|
||||
await shutdownTelemetry(config);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorToHandle) {
|
||||
handleError(errorToHandle, config);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user