diff --git a/src/burp/error.rs b/src/burp/error.rs index 8f69db5..e9ad446 100644 --- a/src/burp/error.rs +++ b/src/burp/error.rs @@ -1,4 +1,6 @@ //! Client error handling +use std::error; +use std::fmt; use std::io; use serde_json; @@ -40,3 +42,17 @@ impl From for Error { Self::Protocol(error.to_string()) } } + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Self::Io(e) => write!(f, "I/O error: {}", e), + Self::Tls(e) => write!(f, "TLS handshake error: {}", e), + Self::Command(e) => write!(f, "Error from BURP server: {}", e), + Self::Protocol(e) => write!(f, "BURP protocol error: {}", e), + Self::UnsupportedVersion(e) => write!(f, "{}", e), + } + } +} + +impl error::Error for Error {}