diff options
| author | Austin Hellyer <[email protected]> | 2016-11-29 20:51:10 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-29 22:27:59 -0800 |
| commit | 93b990d8d1bc9df69b8e27a3db61da570822aad6 (patch) | |
| tree | 6305cf635df90681527a8e736f65ff19f21fd8bc /src/error.rs | |
| parent | Add more shiny readme badges (diff) | |
| download | serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.tar.xz serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.zip | |
Clean up the codebase
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/error.rs b/src/error.rs index 94958fd..eaa2e13 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,9 +1,9 @@ -use std::io::Error as IoError; -use std::error::Error as StdError; -use std::fmt::{self, Display}; use hyper::Error as HyperError; use serde_json::Error as JsonError; use serde_json::Value; +use std::io::Error as IoError; +use std::error::Error as StdError; +use std::fmt::{self, Display, Error as FormatError}; use websocket::result::WebSocketError; use ::client::gateway::GatewayError; use ::client::ClientError; @@ -47,6 +47,8 @@ pub enum Error { Gateway(GatewayError), /// An error while decoding a payload. Decode(&'static str, Value), + /// There was an error with a format. + Format(FormatError), /// An error from the `hyper` crate. Hyper(HyperError), /// An `std::io` error. @@ -73,6 +75,12 @@ pub enum Error { Voice(VoiceError), } +impl From<FormatError> for Error { + fn from(e: FormatError) -> Error { + Error::Format(e) + } +} + impl From<IoError> for Error { fn from(e: IoError) -> Error { Error::Io(e) @@ -122,8 +130,9 @@ impl StdError for Error { fn description(&self) -> &str { match *self { Error::Client(_) => "Client refused a request", - Error::Gateway(ref _inner) => "Gateway error", Error::Decode(msg, _) | Error::Other(msg) => msg, + Error::Format(ref inner) => inner.description(), + Error::Gateway(ref _inner) => "Gateway error", Error::Hyper(ref inner) => inner.description(), Error::Io(ref inner) => inner.description(), Error::Json(ref inner) => inner.description(), |