use air_interpreter_data::Provenance;
use super::instruction_error_definition::error_from_raw_fields;
use super::instruction_error_definition::error_from_raw_fields_w_peerid;
use super::InstructionError;
use crate::execution_step::ErrorAffectable;
use crate::execution_step::RcSecurityTetraplet;
use crate::JValue;
use crate::ToErrorCode;
pub(crate) fn get_instruction_error_from_exec_error(
error: &(impl ErrorAffectable + ToErrorCode + ToString),
instruction: &str,
peer_id_option: Option<&str>,
tetraplet: Option<RcSecurityTetraplet>,
) -> InstructionError {
let provenance = Provenance::literal();
get_instruction_error_from_ingredients(
error.to_error_code(),
&error.to_string(),
instruction,
peer_id_option,
tetraplet,
provenance,
)
}
pub(crate) fn get_instruction_error_from_ingredients(
error_code: i64,
error_message: &str,
instruction: &str,
peer_id_option: Option<&str>,
tetraplet: Option<RcSecurityTetraplet>,
provenance: Provenance,
) -> InstructionError {
let error_object = match peer_id_option {
Some(peer_id) => error_from_raw_fields_w_peerid(error_code, error_message, instruction, peer_id),
None => error_from_raw_fields(error_code, error_message, instruction),
};
get_instruction_error_from_error_object(error_object, tetraplet, provenance)
}
pub(crate) fn get_instruction_error_from_error_object(
error: JValue,
tetraplet: Option<RcSecurityTetraplet>,
provenance: Provenance,
) -> InstructionError {
let orig_catchable = None;
InstructionError {
error,
tetraplet,
provenance,
orig_catchable,
}
}