1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5 #[error("serialization error: {0}")]
6 Serialization(#[from] serde_json::Error),
7
8 #[error("invalid field '{field}': {reason}")]
9 InvalidField { field: &'static str, reason: String },
10
11 #[error("missing required field: {0}")]
12 MissingField(&'static str),
13
14 #[error("invalid state transition from {from} to {to}")]
15 InvalidTransition { from: String, to: String },
16
17 #[error("unsupported message version: {0}")]
18 UnsupportedVersion(String),
19
20 #[error("protocol error {code}: {description}")]
21 Protocol { code: String, description: String },
22}
23
24pub type Result<T> = std::result::Result<T, Error>;