diff options
-rw-r--r-- | src/auth.rs | 6 | ||||
-rw-r--r-- | src/errors/auth.rs | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/auth.rs b/src/auth.rs index 4af4997..be9680b 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1,6 +1,5 @@ //! Deezer API authentication. use std::convert::Infallible; -use std::error::Error; use std::fmt::Display; use std::net::ToSocketAddrs; use std::time::Duration; @@ -48,7 +47,7 @@ pub struct AuthPromptHandler /// Handle for the running authentication prompt handler. /// /// Finishes when a single authentication has occurred. - pub handler: JoinHandle<Result<AuthCode, Box<dyn Error + Send + Sync>>>, + pub handler: JoinHandle<Result<AuthCode, AuthPromptHandlerError>>, } impl AuthPromptHandler @@ -96,7 +95,8 @@ impl AuthPromptHandler } => Ok(auth_code) }?; - Ok(opt_auth_code.map_or_else(|| Err("No auth code was received"), Ok)?) + opt_auth_code + .map_or_else(|| Err(AuthPromptHandlerError::NoAuthCodeReceived), Ok) }); Ok(Self { diff --git a/src/errors/auth.rs b/src/errors/auth.rs index a165e05..b11021c 100644 --- a/src/errors/auth.rs +++ b/src/errors/auth.rs @@ -4,11 +4,19 @@ #[derive(Debug, thiserror::Error)] pub enum AuthPromptHandlerError { - /// HTTP server failed to bind to a address. - #[error("HTTP server failed to bind to address")] + /// Web server failed to bind to a address. + #[error("Web server failed to bind to address")] BindAddressFailed, /// Invalid address. #[error("Invalid address")] InvalidAddress, + + /// Web server failed. + #[error("Web server failed")] + WebServerFailed(#[from] hyper::Error), + + /// No authentication code was received. + #[error("No authentication code was received")] + NoAuthCodeReceived, } |