diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index e1a5b9ef681..cd0232ca761 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -400,4 +400,3 @@ pub enum ReferrerPolicy { OriginWhenCrossOrigin, UnsafeUrl, } - diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index 300d5826edd..f85b6b7dac7 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -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(NetworkError::Internal("load cancelled".to_owned())))); + let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled))); Ok(LoadResult::Cancelled) } @@ -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(NetworkError::Internal("load cancelled".to_owned())))); + let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled))); } return; } diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index fedc3196397..5855cf39448 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -160,6 +160,7 @@ fn load_for_consumer(load_data: LoadData, LoadErrorType::Ssl { .. } => send_error(error.url.clone(), NetworkError::SslValidation(error.url), start_chan), + LoadErrorType::Cancelled => send_error(error.url, NetworkError::LoadCancelled, start_chan), _ => send_error(error.url, NetworkError::Internal(error.error.description().to_owned()), start_chan) } } @@ -983,7 +984,7 @@ fn send_data(context: LoadContext, loop { if cancel_listener.is_cancelled() { - let _ = progress_chan.send(Done(Err(NetworkError::Internal("load cancelled".to_owned())))); + let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled))); return; } diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 4fea45a3a43..f4b7a85e7c5 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -437,9 +437,9 @@ pub enum ConstellationMsg { /// Network errors that have to be exported out of the loaders #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, HeapSizeOf)] pub enum NetworkError { - /// Could be any of the internal errors, like unsupported scheme, load - /// cancellation, connection errors, etc. + /// Could be any of the internal errors, like unsupported scheme, connection errors, etc. Internal(String), + LoadCancelled, /// SSL validation error that has to be handled in the HTML parser SslValidation(Url), } diff --git a/tests/unit/net/resource_thread.rs b/tests/unit/net/resource_thread.rs index 798478285a5..25d455a23a0 100644 --- a/tests/unit/net/resource_thread.rs +++ b/tests/unit/net/resource_thread.rs @@ -220,6 +220,6 @@ fn test_cancelled_listener() { let _ = body_sender.send(body); let response = receiver.recv().unwrap(); assert_eq!(response.progress_port.recv().unwrap(), - ProgressMsg::Done(Err(NetworkError::Internal("load cancelled".to_owned())))); + ProgressMsg::Done(Err(NetworkError::LoadCancelled))); resource_thread.send(ControlMsg::Exit).unwrap(); }