Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpos_drv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ authors = ["Tony Huang <tony@slamtec.com>"]
edition = "2018"

[dependencies]
failure = "0.1.5"
thiserror = "2.0"
26 changes: 10 additions & 16 deletions rpos_drv/src/errors.rs
Original file line number Diff line number Diff line change
@@ -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<T> = std::result::Result<T, Error>;
pub type Result<T> = std::result::Result<T, RposError>;