diff options
author | boastful-squirrel <boastful.squirrel@gmail.com> | 2019-04-22 10:08:40 +0000 |
---|---|---|
committer | boastful-squirrel <boastful.squirrel@gmail.com> | 2019-04-22 10:08:40 +0000 |
commit | 4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1 (patch) | |
tree | 6dce46493f776f22e168877f6f950563942908df /src/auth.rs | |
parent | Fixed syntax error (diff) | |
download | miniserve-4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1.tar.gz miniserve-4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1.zip |
Improved errors
Diffstat (limited to '')
-rw-r--r-- | src/auth.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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<crate::MiniserveConfig> 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 |