From 4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Mon, 22 Apr 2019 12:08:40 +0200 Subject: Improved errors --- src/auth.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/auth.rs') diff --git a/src/auth.rs b/src/auth.rs index 8cedaae..1bdf0be 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -50,10 +50,12 @@ impl Middleware for Auth { let auth_req = match parse_basic_auth(auth_headers) { Ok(auth_req) => auth_req, Err(err) => { - return Ok(Response::Done(HttpResponse::BadRequest().body(format!( - "An error occured during HTTP authentication\ncaused by: {}", - err - )))) + let auth_err = ContextualError::new( + ContextualErrorKind::HTTPAuthenticationError(Box::new(err)), + ); + return Ok(Response::Done( + HttpResponse::BadRequest().body(auth_err.to_string()), + )); } }; if auth_req.username != required_auth.username -- cgit v1.2.3