Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

fix(cli): emit JSON error when session fails to load in --output-format json mode

YeonGyu-Kimcf129c879367
diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs
index a8e47b1e..b399f9a7 100644
--- a/rust/crates/rusty-claude-cli/src/main.rs
+++ b/rust/crates/rusty-claude-cli/src/main.rs
@@ -2221,7 +2221,17 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
match resolve_session_reference(&session_path.display().to_string()) {
Ok(handle) => handle.path,
Err(error) => {
- eprintln!("failed to restore session: {error}");
+ if output_format == CliOutputFormat::Json {
+ eprintln!(
+ "{}",
+ serde_json::json!({
+ "type": "error",
+ "error": format!("failed to restore session: {error}"),
+ })
+ );
+ } else {
+ eprintln!("failed to restore session: {error}");
+ }
std::process::exit(1);
}
}
@@ -2230,7 +2240,17 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
let session = match Session::load_from_path(&resolved_path) {
Ok(session) => session,
Err(error) => {
- eprintln!("failed to restore session: {error}");
+ if output_format == CliOutputFormat::Json {
+ eprintln!(
+ "{}",
+ serde_json::json!({
+ "type": "error",
+ "error": format!("failed to restore session: {error}"),
+ })
+ );
+ } else {
+ eprintln!("failed to restore session: {error}");
+ }
std::process::exit(1);
}
};