1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#![no_std]
#![allow(unused_imports)]
#![allow(stable_features)]
#![feature(global_allocator)]
#![feature(alloc_error_handler, lang_items)]
#![feature(alloc, core_intrinsics)]
#![feature(panic_info_message)]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[macro_use]
extern crate alloc;
#[cfg(feature = "wasm-output-mode")]
#[alloc_error_handler]
fn alloc_error_handler(_layout: alloc::alloc::Layout) -> ! {
elrond_wasm_node::error_hook::signal_error(&b"allocation error"[..])
}
#[cfg(all(feature = "wasm-output-mode", feature = "panic-message"))]
#[panic_handler]
fn panic_fmt(panic_info: &core::panic::PanicInfo) -> ! {
use alloc::string::String;
let panic_msg = if let Some(s) = panic_info.message() {
format!("panic occurred: {:?}", s)
} else {
String::from("unknown panic occurred")
};
elrond_wasm_node::error_hook::signal_error(panic_msg.as_bytes())
}
#[cfg(all(feature = "wasm-output-mode", not(feature = "panic-message")))]
#[panic_handler]
fn panic_fmt(_: &core::panic::PanicInfo) -> ! {
elrond_wasm_node::error_hook::signal_error(&b"panic occurred"[..])
}
#[cfg(feature = "wasm-output-mode")]
#[lang = "eh_personality"]
fn eh_personality() {}