aboutsummaryrefslogtreecommitdiffstats
path: root/src/auth.rs
diff options
context:
space:
mode:
authorboastful-squirrel <boastful.squirrel@gmail.com>2019-04-22 10:08:40 +0000
committerboastful-squirrel <boastful.squirrel@gmail.com>2019-04-22 10:08:40 +0000
commit4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1 (patch)
tree6dce46493f776f22e168877f6f950563942908df /src/auth.rs
parentFixed syntax error (diff)
downloadminiserve-4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1.tar.gz
miniserve-4ddade5bb351b454ebc7c9d6ad69ea40549cf9b1.zip
Improved errors
Diffstat (limited to 'src/auth.rs')
-rw-r--r--src/auth.rs10
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