diff --git a/src/authenticator_delegate.rs b/src/authenticator_delegate.rs index 51650c4..e32f88e 100644 --- a/src/authenticator_delegate.rs +++ b/src/authenticator_delegate.rs @@ -1,6 +1,6 @@ //! Module containing types related to delegates. -use crate::error::{PollError, RefreshError}; +use crate::error::{RefreshError}; use std::error::Error as StdError; use std::fmt; @@ -43,27 +43,6 @@ impl fmt::Display for PollInformation { } } -impl fmt::Display for PollError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - PollError::HttpError(ref err) => err.fmt(f), - PollError::Expired(ref date) => writeln!(f, "Authentication expired at {}", date), - PollError::AccessDenied => "Access denied by user".fmt(f), - PollError::TimedOut => "Timed out waiting for token".fmt(f), - PollError::Other(ref s) => format!("Unknown server error: {}", s).fmt(f), - } - } -} - -impl StdError for PollError { - fn source(&self) -> Option<&(dyn StdError + 'static)> { - match *self { - PollError::HttpError(ref e) => Some(e), - _ => None, - } - } -} - /// A partially implemented trait to interact with the `Authenticator` /// /// The only method that needs to be implemented manually is `present_user_code(...)`, diff --git a/src/error.rs b/src/error.rs index 619b984..ae0fca8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -46,6 +46,27 @@ pub enum PollError { Other(String), } +impl fmt::Display for PollError { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + match *self { + PollError::HttpError(ref err) => err.fmt(f), + PollError::Expired(ref date) => writeln!(f, "Authentication expired at {}", date), + PollError::AccessDenied => "Access denied by user".fmt(f), + PollError::TimedOut => "Timed out waiting for token".fmt(f), + PollError::Other(ref s) => format!("Unknown server error: {}", s).fmt(f), + } + } +} + +impl StdError for PollError { + fn source(&self) -> Option<&(dyn StdError + 'static)> { + match *self { + PollError::HttpError(ref e) => Some(e), + _ => None, + } + } +} + /// Encapsulates all possible results of the `token(...)` operation #[derive(Debug)] pub enum Error {