Redirect to an error page when file's not found

This commit is contained in:
Ravi Shankar 2015-11-25 02:30:07 +05:30
parent 3eef814c4d
commit b17ca9bdc1
4 changed files with 24 additions and 5 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use about_loader;
use mime_classifier::MIMEClassifier;
use net_traits::ProgressMsg::{Done, Payload};
use net_traits::{LoadConsumer, LoadData, Metadata};
@ -13,6 +14,7 @@ use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use std::sync::Arc;
use url::Url;
use util::task::spawn_named;
static READ_SIZE: usize = 8192;
@ -96,8 +98,13 @@ pub fn factory(load_data: LoadData,
}
};
}
Err(e) => {
send_error(url, e.description().to_owned(), senders);
Err(_) => {
// this should be one of the three errors listed in
// http://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.open
// but, we'll go for a "file not found!"
let url = Url::parse("about:not-found").unwrap();
let load_data_404 = LoadData::new(url, None);
about_loader::factory(load_data_404, senders, classifier, cancel_listener)
}
}
}