mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-04-10 17:59:37 +08:00
fix(cli): emit JSON error when session fails to load in --output-format json mode
'failed to restore session' errors from both the path-resolution step
and the JSONL-load step now check output_format and emit:
{"type":"error","error":"failed to restore session: <detail>"}
instead of bare eprintln prose.
Covers: session not found, corrupt JSONL, permission errors.
This commit is contained in:
parent
c0248253ac
commit
cf129c8793
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user