aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs27
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 {