Skip to content

Commit a1027b1

Browse files
CLI: decorate runtime errors with call-stack trace
format_error_with_trace was already implemented but the CLI was discarding the trace by printing only the bare error string. Wire it into the two top-level execute() sites so users see WHERE the error fired, not just what. ## Before Error: Index out of bounds: xs[99] (length 3). ... ## After Error: Index out of bounds: xs[99] (length 3). ... at inner (6:11) at main (8:1) This composes with all the other error improvements: - name+length+hint at the point of failure (this commit's wiring makes that visible) - did-you-mean for undefined variables - reserved-word and `if x = 5` hints from the parser - cross-container hints (arr_get on dict → suggests dict_get) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e9009ee commit a1027b1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

omnimcode-cli/src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,12 @@ fn execute_program(source: &str) -> Result<(), String> {
10791079
}
10801080
}
10811081
}
1082-
interpreter.execute(statements)?;
1082+
// Decorate runtime errors with the call-stack trace so users see
1083+
// WHERE the error happened, not just what. format_error_with_trace
1084+
// is a no-op when the message already has trace lines.
1085+
interpreter.execute(statements).map_err(|e| {
1086+
interpreter.format_error_with_trace(&e)
1087+
})?;
10831088

10841089
Ok(())
10851090
}
@@ -1229,7 +1234,7 @@ fn repl_execute(
12291234
}
12301235

12311236
if let Err(e) = interp.execute(statements) {
1232-
eprintln!("Error: {}", e);
1237+
eprintln!("Error: {}", interp.format_error_with_trace(&e));
12331238
}
12341239
}
12351240

0 commit comments

Comments
 (0)