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
use move_core_types::{
errmap::{ErrorContext, ErrorMapping},
language_storage::ModuleId,
};
use once_cell::sync::Lazy;
static RELEASE_ERRMAP_BYTES: &[u8] = include_bytes!("../release_errmap/error_description.errmap");
static RELEASE_ERRMAP: Lazy<ErrorMapping> = Lazy::new(|| {
bcs::from_bytes(RELEASE_ERRMAP_BYTES).expect("Failed to deserialize static error descriptions")
});
pub fn get_explanation(module_id: &ModuleId, abort_code: u64) -> Option<ErrorContext> {
let errmap = &*RELEASE_ERRMAP;
errmap.get_explanation(module_id, abort_code)
}
#[cfg(test)]
mod tests {
use super::*;
use move_core_types::{account_address::AccountAddress, ident_str};
#[test]
fn test_get_explanation() {
let module_id = ModuleId::new(AccountAddress::ZERO, ident_str!("TESTTEST").to_owned());
let _ = get_explanation(&module_id, 1234);
}
}