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
use crate::{error_hook, VmApiImpl};
use elrond_wasm::api::{ErrorApi, ErrorApiImpl, Handle};

extern "C" {
    fn managedSignalError(messageHandle: i32) -> !;
}

impl ErrorApi for VmApiImpl {
    type ErrorApiImpl = VmApiImpl;

    #[inline]
    fn error_api_impl() -> Self {
        VmApiImpl {}
    }
}

impl ErrorApiImpl for VmApiImpl {
    #[inline(always)]
    fn signal_error(&self, message: &[u8]) -> ! {
        error_hook::signal_error(message)
    }

    #[inline(always)]
    fn signal_error_from_buffer(&self, message_handle: Handle) -> ! {
        unsafe { managedSignalError(message_handle) }
    }
}