Skip to content

Commit

Permalink
rune: Do not trace return value (causes panic on Result:Err) (#748)
Browse files Browse the repository at this point in the history
Do not trace return value (causes panic on Result:Err)

Instead attempt to print *something*
  • Loading branch information
VorpalBlade authored Jul 17, 2024
1 parent 4fc0395 commit e3ca8ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion crates/rune/src/runtime/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,15 @@ impl fmt::Debug for Value {
let mut o = Formatter::new();

if self.string_debug(&mut o).is_err() {
return Err(fmt::Error);
match self.type_info() {
Ok(type_info) => {
write!(f, "<{} object at {:p}>", type_info, self)?;
}
Err(e) => {
write!(f, "<unknown object at {:p}: {}>", self, e)?;
}
}
return Ok(());
}

f.write_str(o.as_str())?;
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/runtime/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ impl Vm {
}

#[inline]
#[tracing::instrument(skip(self))]
#[tracing::instrument(skip(self, return_value))]
fn op_return_internal(&mut self, return_value: Value) -> VmResult<Option<Output>> {
let (exit, out) = vm_try!(self.pop_call_frame());

Expand Down

0 comments on commit e3ca8ab

Please sign in to comment.