Skip to content

Commit

Permalink
Few small fixes to error debug events (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Oct 31, 2022
1 parent 89e3948 commit 4b42366
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions soroban-env-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ impl Host {
.msg("error '{}': calling unknown contract function '{}'")
.arg::<RawVal>(func.into()),
)),
Err(_panic_payload) => {
Err(panic_payload) => {
// Return an error indicating the contract function
// panicked. If if was a panic generated by a
// CheckedEnv-upgraded HostError, it had its status
Expand All @@ -875,21 +875,21 @@ impl Host {
// propagate it.
let func: RawVal = func.into();
let mut status: Status = ScUnknownErrorCode::General.into();
let mut event = DebugEvent::new().msg("Caught panic from contract function '{}'").arg(func);
let mut event = DebugEvent::new().msg("caught panic from contract function '{}'").arg(func);

if let Some(st) = *panic.borrow() {
status = st;
event = DebugEvent::new().msg("Caught panic from contract function '{}', propagating escalated error '{}'").arg(func);
event = DebugEvent::new().msg("caught panic from contract function '{}', propagating escalated error '{}'").arg(func).arg(st.to_raw());
}
// If we're allowed to record dynamic strings (which happens in
// native test configurations), also log the panic payload into
// the .
else if cfg!(feature = "hostfn_log_fmt_values") {
if let Some(str) = _panic_payload.downcast_ref::<&str>() {
let msg: String = format!("Caught panic '{}' from contract function '{:?}'", str, func);
if let Some(str) = panic_payload.downcast_ref::<&str>() {
let msg: String = format!("caught panic '{}' from contract function '{:?}'", str, func);
event = DebugEvent::new().msg(msg);
} else if let Some(str) = _panic_payload.downcast_ref::<String>() {
let msg: String = format!("Caught panic '{}' from contract function '{:?}'", str, func);
} else if let Some(str) = panic_payload.downcast_ref::<String>() {
let msg: String = format!("caught panic '{}' from contract function '{:?}'", str, func);
event = DebugEvent::new().msg(msg);
}
}
Expand Down

0 comments on commit 4b42366

Please sign in to comment.