From 45156c46c902576846c56cdf0b7b45573f4d1bce Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Tue, 29 May 2018 10:42:53 -0700 Subject: [PATCH] map `actix_web::error::Error` to `std::io::Error` as string. Conversion is by way of the `Display` trait impl since the actix errors all seem to be more concerned with converting to/from http responses rather than standard errors. --- src/cmd/serve.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index e7d4829a..36f1eaa5 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -117,7 +117,12 @@ fn handle_directory<'a, 'b>(dir: &'a fs::Directory, req: &'b HttpRequest) -> io: let mut path = PathBuf::from(&dir.base); path.push(&dir.path); path.push("index.html"); - Ok(fs::NamedFile::open(path).respond_to(req).unwrap()) + fs::NamedFile::open(path) + .respond_to(req) + // Didn't see a clear path from + // `actix_web::error::Error` to `std::error::Error` + // so being "cheap" and just leveraging the Display impl to wrap it. + .map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e))) } pub fn serve(interface: &str, port: &str, output_dir: &str, base_url: &str, config_file: &str) -> Result<()> {