From 0e0cd244f32bd30c6b7a377d0fb29cf8c024c7fa Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Thu, 31 May 2018 11:39:43 -0700 Subject: [PATCH] Fix error handling put in place to side-step a confusing compiler error. I filed actix/actix-web#261 as per the maintaner's request while working on #310. Having looked at the issue this morning, it appeared there was an implementation to convert `io::Result` into a `Responder`, which kicked in when I tried to access the `respond_to()` method without getting the inner type from that first result before hand. --- src/cmd/serve.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 36f1eaa5..db50a050 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -117,12 +117,7 @@ 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"); - 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))) + fs::NamedFile::open(path)?.respond_to(req) } pub fn serve(interface: &str, port: &str, output_dir: &str, base_url: &str, config_file: &str) -> Result<()> {