diff options
| author | Max Audron <audron@cocaine.farm> | 2025-02-22 22:59:01 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2025-02-22 22:59:01 +0100 |
| commit | b8ad94cd5061445a45d0790eee36014d34ad6817 (patch) | |
| tree | fb7d11e136b968d2f2b3593ba9163894baed8912 /src/error/mod.rs | |
| parent | update dependencies and fix errors (diff) | |
replace deprecated failure crate with thiserror
this changes the public API in that all our methods now return a proper
ProtocolError crate. Needed change anyways to properly deal with all our
errors in the long run.
Will still need to do a pass through the crate to remove all existing
unwraps where it makes sense.
Diffstat (limited to 'src/error/mod.rs')
| -rw-r--r-- | src/error/mod.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs index 5553987..b415c98 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1,22 +1,26 @@ - #[derive(Debug, Fail)] +use thiserror::Error; + +#[derive(Debug, Error)] pub enum ProtocolError { - #[fail(display = "message has wrong type")] + #[error("message has wrong type")] WrongMsgType, - #[fail(display = "bool value is neither 0 nor 1")] + #[error("bool value is neither 0 nor 1")] BoolOutOfRange, - #[fail(display = "QVariant is not known")] + #[error("QVariant is not known")] UnknownVariant, - #[fail(display = "wrong variant has been given")] + #[error("wrong variant has been given")] WrongVariant, - #[fail(display = "io error")] - IOError(std::io::Error), - #[fail(display = "could not convert from int")] - TryFromIntError(std::num::TryFromIntError), - #[fail(display = "utf8 error")] - Utf8Error(std::string::FromUtf8Error), - #[fail(display = "failed to parse char as utf16")] + #[error("io error: {0}")] + IOError(#[from] std::io::Error), + #[error("could not convert from int: {0}")] + TryFromIntError(#[from] std::num::TryFromIntError), + #[error("utf8 error: {0}")] + Utf8Error(#[from] std::string::FromUtf8Error), + #[error("errored to parse char as utf16")] CharError, - } + #[error("failed to deal with time: {0}")] + TimeError(#[from] time::error::ComponentRange), +} // impl std::error::Error for ErrorKind {} // |
