aboutsummaryrefslogtreecommitdiffstats
path: root/src/file_upload.rs
diff options
context:
space:
mode:
authorboastful-squirrel <boastful.squirrel@gmail.com>2019-04-21 22:39:38 +0000
committerboastful-squirrel <boastful.squirrel@gmail.com>2019-04-21 22:39:38 +0000
commit6dad3eb1bf0cb3b36cdb3b312cca7caa91de2f57 (patch)
treefffc75935db79ef4b08c8502f5afe9ca9470867a /src/file_upload.rs
parentPrint upload/archive errors also in terminal (diff)
downloadminiserve-6dad3eb1bf0cb3b36cdb3b312cca7caa91de2f57.tar.gz
miniserve-6dad3eb1bf0cb3b36cdb3b312cca7caa91de2f57.zip
Properly log error + added render_error method
Diffstat (limited to 'src/file_upload.rs')
-rw-r--r--src/file_upload.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/file_upload.rs b/src/file_upload.rs
index 54c56dd..3b84721 100644
--- a/src/file_upload.rs
+++ b/src/file_upload.rs
@@ -10,8 +10,8 @@ use std::{
path::{Component, PathBuf},
};
-use crate::errors::ContextualErrorKind;
-use crate::renderer::file_upload_error;
+use crate::errors::{self, ContextualErrorKind};
+use crate::renderer;
/// Query parameters
#[derive(Debug, Deserialize)]
@@ -31,11 +31,11 @@ fn save_file(
)));
}
- let mut file = match std::fs::File::create(file_path) {
+ let mut file = match std::fs::File::create(&file_path) {
Ok(file) => file,
Err(e) => {
return Box::new(future::err(ContextualErrorKind::IOError(
- "Failed to create file".to_string(),
+ format!("Failed to create file in {}", file_path.display()),
e,
)));
}
@@ -175,10 +175,10 @@ fn create_error_response(
description: &str,
return_path: &str,
) -> FutureResult<HttpResponse, actix_web::error::Error> {
- log::error!("{}", description);
+ errors::log_error_chain(description.to_string());
future::ok(
HttpResponse::BadRequest()
.content_type("text/html; charset=utf-8")
- .body(file_upload_error(description, return_path).into_string()),
+ .body(renderer::render_error(description, return_path).into_string()),
)
}