Refactor execution errors (#198)

This commit is contained in:
Mike Voronov
2021-12-21 11:37:35 +03:00
committed by GitHub
parent 54e383cdaf
commit f69b5aa728
58 changed files with 695 additions and 405 deletions

View File

@ -106,3 +106,28 @@ pub fn print_trace(result: &RawAVMOutcome, trace_name: &str) {
}
println!("]");
}
#[macro_export]
macro_rules! rc {
($expr:expr) => {
std::rc::Rc::new($expr)
};
}
use air::ToErrorCode;
use air_interpreter_interface::INTERPRETER_SUCCESS;
pub fn is_interpreter_succeded(result: &RawAVMOutcome) -> bool {
result.ret_code == INTERPRETER_SUCCESS
}
pub fn check_error(result: &RawAVMOutcome, error: impl ToErrorCode + ToString) -> bool {
println!(
"{} == {} || {} == {}",
result.ret_code,
error.to_error_code(),
result.error_message,
error.to_string()
);
result.ret_code == error.to_error_code() && result.error_message == error.to_string()
}