use std::num::ParseIntError; use serde_json::Error as JsonError; use thiserror::Error; /// Result type for state resolution. pub type Result = std::result::Result; /// Represents the various errors that arise when resolving state. #[derive(Error, Debug)] pub enum Error { /// A deserialization error. #[error(transparent)] SerdeJson(#[from] JsonError), /// An error that occurs when converting from JSON numbers to rust. #[error(transparent)] IntParseError(#[from] ParseIntError), #[error("Not found error: {0}")] NotFound(String), #[error("Invalid PDU: {0}")] InvalidPdu(String), #[error("Conversion failed: {0}")] ConversionError(String), #[error("{0}")] Custom(Box), } impl Error { pub fn custom(e: E) -> Self { Self::Custom(Box::new(e)) } }