Deduplicate stacktrace in Fennel error output
Strip the stack traceback from the FennelError::Eval message so it
only appears once via the source chain, instead of being shown in
both the outer message and the miette cause section.
Assisted-by: GLM-5.1 via pi
diff --git a/src/fennel.rs b/src/fennel.rs
index 2647ae5..d103f26 100644
--- a/src/fennel.rs
+++ b/src/fennel.rs
@@ -153,7 +153,14 @@ impl FennelError {
/// Construct an `Eval` error from an mlua error, extracting line
/// information when available.
pub(crate) fn from_lua(source: &str, name: &str, err: mlua::Error) -> Self {
- let message = format!("{name}: {err}");
+ // Strip the stack traceback from the message so it only appears
+ // once (via the source chain rendered by miette).
+ let err_display = format!("{err}");
+ let err_body = err_display
+ .split_once("\nstack traceback:")
+ .map(|(msg, _)| msg)
+ .unwrap_or(&err_display);
+ let message = format!("{name}: {err_body}");
// Try to extract a line number from the Lua error for a label.
let offset = extract_line_offset(&err)