Skip to content

Commit

Permalink
Remove install_panic_handler from non-wasm32 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed May 11, 2022
1 parent d37cc82 commit 95f2528
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions packages/std/src/panic.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/// When compiled to Wasm, this installs a panic handler that aborts the
/// contract execution and sends the panic message and location to the host.
/// For other targets, this is a noop.
/// Installs a panic handler that aborts the contract execution
/// and sends the panic message and location to the host.
///
/// This overrides any previous panic handler. See <https://doc.rust-lang.org/std/panic/fn.set_hook.html>
/// for details.
#[cfg(feature = "abort")]
#[cfg(all(feature = "abort", target_arch = "wasm32"))]
pub fn install_panic_handler() {
#[cfg(target_arch = "wasm32")]
{
use super::imports::handle_panic;
std::panic::set_hook(Box::new(|info| {
// E.g. "panicked at 'oh no (a = 3)', src/contract.rs:51:5"
let full_message = info.to_string();
handle_panic(&full_message);
}));
}
use super::imports::handle_panic;
std::panic::set_hook(Box::new(|info| {
// E.g. "panicked at 'oh no (a = 3)', src/contract.rs:51:5"
let full_message = info.to_string();
handle_panic(&full_message);
}));
}

0 comments on commit 95f2528

Please sign in to comment.