Skip to main content

runmat_execution/
error.rs

1use thiserror::Error;
2
3#[derive(Clone, Debug, Eq, Error, PartialEq)]
4pub enum ContractError {
5    #[error("invalid {field}: {reason}")]
6    Invalid { field: &'static str, reason: String },
7    #[error("{field} exceeds its limit of {limit}")]
8    Limit { field: &'static str, limit: u64 },
9    #[error("unsupported schema {actual}; supported schema is {supported}")]
10    UnsupportedSchema { actual: u16, supported: u16 },
11    #[error("protocol message is malformed: {0}")]
12    MalformedProtocol(String),
13}
14
15impl ContractError {
16    pub(crate) fn invalid(field: &'static str, reason: impl Into<String>) -> Self {
17        Self::Invalid {
18            field,
19            reason: reason.into(),
20        }
21    }
22}