diff --git a/rpos_drv/Cargo.toml b/rpos_drv/Cargo.toml index e8d6cec..715945d 100644 --- a/rpos_drv/Cargo.toml +++ b/rpos_drv/Cargo.toml @@ -9,4 +9,4 @@ authors = ["Tony Huang "] edition = "2018" [dependencies] -failure = "0.1.5" +thiserror = "2.0" diff --git a/rpos_drv/src/errors.rs b/rpos_drv/src/errors.rs index a1931d7..beedf8a 100644 --- a/rpos_drv/src/errors.rs +++ b/rpos_drv/src/errors.rs @@ -1,30 +1,24 @@ -pub use failure::{ Fail, Error }; - -#[derive(Fail, Debug)] +#[derive(thiserror::Error, Debug)] pub enum RposError { /// The execution of operation failed - #[fail(display="operation failed: {}", description)] - OperationFail { - description: String - }, + #[error("operation failed: {}", description)] + OperationFail { description: String }, /// The execution of operation is timed out - #[fail(display="operation timeout")] + #[error("operation timeout")] OperationTimeout, /// The device doesn't support this operation - #[fail(display="operation not support")] + #[error("operation not support")] OperationNotSupport, /// The decoding data is invalid according to current protocol - #[fail(display="protocol error: {}", description)] - ProtocolError { - description: String - }, + #[error("protocol error: {}", description)] + ProtocolError { description: String }, /// The buffer is too small for message encoding - #[fail(display="buffer is too small for message encoding")] - BufferTooSmall + #[error("buffer is too small for message encoding")] + BufferTooSmall, } -pub type Result = std::result::Result; +pub type Result = std::result::Result;