Skip to main content

vrs_core_sdk/
error.rs

1use codec::{Decode, Encode};
2
3#[derive(Debug, Clone, Decode, Encode)]
4pub enum RuntimeError {
5    #[codec(index = 0)]
6    DecodeReturnValueError,
7    #[codec(index = 1)]
8    ReadOnly,
9    #[codec(index = 2)]
10    MemoryAccessOutOfBounds,
11    #[codec(index = 3)]
12    KvStorageError(String),
13    #[codec(index = 4)]
14    HttpError(String),
15    #[codec(index = 5)]
16    TimerError(String),
17    #[codec(index = 6)]
18    TssError(String),
19}
20
21impl core::fmt::Display for RuntimeError {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        match self {
24            RuntimeError::DecodeReturnValueError => write!(f, "Decode return value error"),
25            RuntimeError::ReadOnly => write!(f, "Write is not allowed in Read-only mode"),
26            RuntimeError::MemoryAccessOutOfBounds => write!(f, "Memory access out of bounds"),
27            RuntimeError::KvStorageError(e) => write!(f, "Kv storage error: {}", e),
28            RuntimeError::HttpError(e) => write!(f, "Http error: {}", e),
29            RuntimeError::TimerError(e) => write!(f, "Timer error: {}", e),
30            RuntimeError::TssError(e) => write!(f, "Tss error: {}", e),
31        }
32    }
33}