diff options
author | Glenn Watson <gw@intuitionlibrary.com> | 2014-09-11 14:22:59 +1000 |
---|---|---|
committer | Glenn Watson <gw@intuitionlibrary.com> | 2014-09-11 14:22:59 +1000 |
commit | 627359e9e4f3c3958da903d7eb1a165b33b6f408 (patch) | |
tree | c5804ad12f5db9aa9796ca3e1fd22e055cdf72be /components/net/file_loader.rs | |
parent | 3bd5ef3384610f6d666dedc9a5099f0c9d6d2cfc (diff) | |
download | servo-627359e9e4f3c3958da903d7eb1a165b33b6f408.tar.gz servo-627359e9e4f3c3958da903d7eb1a165b33b6f408.zip |
Return error when unable to create a file path from url.
Diffstat (limited to 'components/net/file_loader.rs')
-rw-r--r-- | components/net/file_loader.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index df775775beb..73a1d81cc27 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -35,16 +35,23 @@ pub fn factory() -> LoaderTask { assert!("file" == url.scheme.as_slice()); let progress_chan = start_sending(start_chan, Metadata::default(url.clone())); spawn_named("file_loader", proc() { - let file_path: Path = url.to_file_path().unwrap(); - match File::open_mode(&Path::new(file_path), io::Open, io::Read) { - Ok(ref mut reader) => { - let res = read_all(reader as &mut io::Stream, &progress_chan); - progress_chan.send(Done(res)); + let file_path: Result<Path, ()> = url.to_file_path(); + match file_path { + Ok(file_path) => { + match File::open_mode(&Path::new(file_path), io::Open, io::Read) { + Ok(ref mut reader) => { + let res = read_all(reader as &mut io::Stream, &progress_chan); + progress_chan.send(Done(res)); + } + Err(e) => { + progress_chan.send(Done(Err(e.desc.to_string()))); + } + } } - Err(e) => { - progress_chan.send(Done(Err(e.desc.to_string()))); + Err(_) => { + progress_chan.send(Done(Err(url.to_string()))); } - }; + } }); }; f |