mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Propagating the load errors from network loader
This commit is contained in:
parent
8d988f20c1
commit
5e6f32a59b
15 changed files with 208 additions and 152 deletions
|
@ -6,7 +6,7 @@ use about_loader;
|
|||
use mime_classifier::MIMEClassifier;
|
||||
use mime_guess::guess_mime_type;
|
||||
use net_traits::ProgressMsg::{Done, Payload};
|
||||
use net_traits::{LoadConsumer, LoadData, Metadata};
|
||||
use net_traits::{LoadConsumer, LoadData, Metadata, NetworkError};
|
||||
use resource_thread::{CancellationListener, ProgressSender};
|
||||
use resource_thread::{send_error, start_sending_sniffed_opt};
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -50,7 +50,7 @@ fn read_all(reader: &mut File, progress_chan: &ProgressSender, cancel_listener:
|
|||
ReadStatus::EOF => return Ok(LoadResult::Finished),
|
||||
}
|
||||
}
|
||||
let _ = progress_chan.send(Done(Err("load cancelled".to_owned())));
|
||||
let _ = progress_chan.send(Done(Err(NetworkError::Internal("load cancelled".to_owned()))));
|
||||
Ok(LoadResult::Cancelled)
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ pub fn factory(load_data: LoadData,
|
|||
let file_path = match load_data.url.to_file_path() {
|
||||
Ok(file_path) => file_path,
|
||||
Err(_) => {
|
||||
send_error(load_data.url, "Could not parse path".to_owned(), senders);
|
||||
send_error(load_data.url, NetworkError::Internal("Could not parse path".to_owned()), senders);
|
||||
return;
|
||||
},
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ pub fn factory(load_data: LoadData,
|
|||
if cancel_listener.is_cancelled() {
|
||||
if let Ok(progress_chan) = get_progress_chan(load_data, file_path,
|
||||
senders, classifier, &[]) {
|
||||
let _ = progress_chan.send(Done(Err("load cancelled".to_owned())));
|
||||
let _ = progress_chan.send(Done(Err(NetworkError::Internal("load cancelled".to_owned()))));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ pub fn factory(load_data: LoadData,
|
|||
}
|
||||
}
|
||||
Err(e) => {
|
||||
send_error(load_data.url, e, senders);
|
||||
send_error(load_data.url, NetworkError::Internal(e), senders);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue