1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

use errmapgen::{ErrorContext, ErrorMapping};
use move_core_types::language_storage::ModuleId;

/// Given the module ID and the abort code raised from that module, returns the human-readable
/// explanation of that abort if possible.
pub fn get_explanation(module_id: &ModuleId, abort_code: u64) -> Option<ErrorContext> {
    let error_descriptions: ErrorMapping =
        lcs::from_bytes(compiled_stdlib::ERROR_DESCRIPTIONS).unwrap();
    error_descriptions.get_explanation(module_id, abort_code)
}