multiversx_chain_vm/tx_mock/
tx_panic.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use multiversx_chain_core::types::ReturnCode;

#[derive(Debug, Clone)]
pub struct TxPanic {
    pub status: ReturnCode,
    pub message: String,
}

impl TxPanic {
    pub fn new(status: ReturnCode, message: &str) -> Self {
        Self {
            status,
            message: message.to_string(),
        }
    }

    pub fn user_error(message: &str) -> TxPanic {
        TxPanic::new(ReturnCode::UserError, message)
    }

    pub fn vm_error(message: &str) -> TxPanic {
        TxPanic::new(ReturnCode::ExecutionFailed, message)
    }
}