Repository navigation
fix(claude_code): surface structured stdout errors on nonzero exit #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f20382
d973239
385ea8b
7fd3d89
ac665e7
1177b59
026af85
0f36597
8c7a01f
055f587
937e156
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,7 @@ impl EventMapper { | |
| subtype, | ||
| usage, | ||
| total_cost_usd, | ||
| .. | ||
| raw, | ||
| } => { | ||
| let mut parsed = usage.as_ref().map(parse_usage); | ||
| // CC stream emits `total_cost_usd` on the terminal `result` | ||
|
|
@@ -120,8 +120,20 @@ impl EventMapper { | |
| usage.charged_amount_usd = cost; | ||
| } | ||
| self.usage = parsed; | ||
| if subtype.as_deref() == Some("error") && self.error.is_none() { | ||
| self.error = Some("claude reported `result.subtype=error`".into()); | ||
| // A failed turn is reported as `subtype=error` or as | ||
| // `is_error=true` with the human-readable reason in `result`. | ||
| let failed = subtype.as_deref() == Some("error") | ||
| || raw.get("is_error").and_then(Value::as_bool) == Some(true); | ||
| if failed && self.error.is_none() { | ||
|
senamakel marked this conversation as resolved.
|
||
| let reason = raw | ||
| .get("result") | ||
| .and_then(Value::as_str) | ||
| .map(str::trim) | ||
| .filter(|reason| !reason.is_empty()); | ||
|
Comment on lines
+128
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Claude returns a failed Useful? React with 👍 / 👎. |
||
| self.error = Some(match reason { | ||
|
senamakel marked this conversation as resolved.
|
||
| Some(reason) => reason.to_string(), | ||
|
senamakel marked this conversation as resolved.
|
||
| None => "claude reported `result.subtype=error`".into(), | ||
| }); | ||
| } | ||
| self.finished = true; | ||
| Vec::new() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.