mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -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()
|
? new StreamJsonFormatter()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
let errorToHandle: unknown | undefined;
|
||||||
try {
|
try {
|
||||||
consolePatcher.patch();
|
consolePatcher.patch();
|
||||||
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
||||||
@@ -213,6 +214,8 @@ export async function runNonInteractive(
|
|||||||
message: 'Maximum session turns exceeded',
|
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) {
|
} catch (error) {
|
||||||
handleError(error, config);
|
errorToHandle = error;
|
||||||
} finally {
|
} finally {
|
||||||
consolePatcher.cleanup();
|
consolePatcher.cleanup();
|
||||||
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
||||||
@@ -310,5 +313,9 @@ export async function runNonInteractive(
|
|||||||
await shutdownTelemetry(config);
|
await shutdownTelemetry(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errorToHandle) {
|
||||||
|
handleError(errorToHandle, config);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user