diff options
author | Alex Auvolat <alex@adnab.me> | 2022-09-01 12:15:50 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-09-01 12:15:50 +0200 |
commit | cd203f5708907c2bf172a3c5b7c5b40e2557b2f4 (patch) | |
tree | 8b3eb284106d0f6b5af1ad4ad447c8004ff4c6f5 /src/error.rs | |
parent | 745c78618479c4177647e4d7fed97d5fd2d00d4f (diff) | |
download | netapp-cd203f5708907c2bf172a3c5b7c5b40e2557b2f4.tar.gz netapp-cd203f5708907c2bf172a3c5b7c5b40e2557b2f4.zip |
Add OrderTag to Req and Resp, refactor errors
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/src/error.rs b/src/error.rs index 2fa4594..c0aeeac 100644 --- a/src/error.rs +++ b/src/error.rs @@ -28,6 +28,9 @@ pub enum Error { #[error(display = "Framing protocol error")] Framing, + #[error(display = "Remote error ({:?}): {}", _0, _1)] + Remote(io::ErrorKind, String), + #[error(display = "Request ID collision")] IdCollision, @@ -42,30 +45,6 @@ pub enum Error { #[error(display = "Version mismatch: {}", _0)] VersionMismatch(String), - - #[error(display = "Remote error {}: {}", _0, _1)] - Remote(u8, String), -} - -impl Error { - pub fn code(&self) -> u8 { - match self { - Self::Io(_) => 100, - Self::TokioJoin(_) => 110, - Self::OneshotRecv(_) => 111, - Self::RMPEncode(_) => 10, - Self::RMPDecode(_) => 11, - Self::UTF8(_) => 12, - Self::Framing => 13, - Self::NoHandler => 20, - Self::ConnectionClosed => 21, - Self::IdCollision => 22, - Self::Handshake(_) => 30, - Self::VersionMismatch(_) => 31, - Self::Remote(c, _) => *c, - Self::Message(_) => 99, - } - } } impl<T> From<tokio::sync::watch::error::SendError<T>> for Error { |