Skip to main content

runmat_runtime/execution/value_codec/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, PartialEq, Eq)]
4pub enum ValueCodecError {
5    #[error("value at `{path}` is not portable: {rule}")]
6    Unsupported { path: String, rule: &'static str },
7    #[error("invalid value payload at `{path}`: {message}")]
8    Invalid { path: String, message: String },
9}
10
11impl ValueCodecError {
12    pub(super) fn unsupported(path: &str, rule: &'static str) -> Self {
13        Self::Unsupported {
14            path: path.to_owned(),
15            rule,
16        }
17    }
18
19    pub(super) fn invalid(path: &str, message: impl Into<String>) -> Self {
20        Self::Invalid {
21            path: path.to_owned(),
22            message: message.into(),
23        }
24    }
25}