aboutsummaryrefslogtreecommitdiffstats
path: root/src/listing.rs
diff options
context:
space:
mode:
authorboastful-squirrel <boastful.squirrel@gmail.com>2019-05-02 20:00:44 +0000
committerboastful-squirrel <boastful.squirrel@gmail.com>2019-05-02 20:00:44 +0000
commit74b95a37ee569e5d06577d80703fbb246a254bf5 (patch)
tree158e2d8f68f934e2b64e94857baaf30c8947f80e /src/listing.rs
parentDisplay path instead of uri in 404 error (diff)
downloadminiserve-74b95a37ee569e5d06577d80703fbb246a254bf5.tar.gz
miniserve-74b95a37ee569e5d06577d80703fbb246a254bf5.zip
Print error when parsing query parameters fail
Diffstat (limited to 'src/listing.rs')
-rw-r--r--src/listing.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/listing.rs b/src/listing.rs
index 2e3093d..2d00836 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -11,7 +11,7 @@ use std::time::SystemTime;
use strum_macros::{Display, EnumString};
use crate::archive::{self, CompressionMethod};
-use crate::errors;
+use crate::errors::{self, ContextualError};
use crate::renderer;
use crate::themes::ColorScheme;
@@ -305,15 +305,18 @@ pub fn extract_query_parameters<S>(
Option<ColorScheme>,
Option<PathBuf>,
) {
- if let Ok(query) = Query::<QueryParameters>::extract(req) {
- (
+ match Query::<QueryParameters>::extract(req) {
+ Ok(query) => (
query.sort,
query.order,
query.download.clone(),
query.theme,
query.path.clone(),
- )
- } else {
- (None, None, None, None, None)
+ ),
+ Err(e) => {
+ let err = ContextualError::ParseError("query parameters".to_string(), e.to_string());
+ errors::log_error_chain(err.to_string());
+ (None, None, None, None, None)
+ }
}
}