mirror of
https://github.com/servo/servo.git
synced 2025-06-28 02:53:48 +01:00
Auto merge of #10785 - frewsxcv:loaderrortype-nostring, r=jdm
Refactor `LoadErrorType` to not require a `String` for every type. Some of the `LoadErrorType` like `LoadCancelled` don't need a `String` associated with the type since the variant is self-explanatory. There are some variants that don't need an associated `String`, but that can be cleaned up in a later refactor. Also, `net_traits::NetworkError` currently requires a `String`, but that can potentially also be refactored away too. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10785) <!-- Reviewable:end -->
This commit is contained in:
commit
81f6e70a62
2 changed files with 64 additions and 43 deletions
|
@ -1082,8 +1082,7 @@ fn test_load_errors_when_there_a_redirect_loop() {
|
|||
|
||||
match load(&load_data, &ui_provider, &http_state, None, &Factory,
|
||||
DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None)) {
|
||||
Err(ref load_err) if load_err.error == LoadErrorType::InvalidRedirect =>
|
||||
assert_eq!(&load_err.reason, "redirect loop"),
|
||||
Err(ref load_err) if load_err.error == LoadErrorType::RedirectLoop => (),
|
||||
_ => panic!("expected max redirects to fail")
|
||||
}
|
||||
}
|
||||
|
@ -1172,7 +1171,7 @@ impl HttpRequestFactory for DontConnectFactory {
|
|||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, _: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
Err(LoadError::new(url, LoadErrorType::Connection, "should not have connected".to_owned()))
|
||||
Err(LoadError::new(url, LoadErrorType::Connection { reason: "should not have connected".into() }))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1189,7 @@ fn test_load_errors_when_scheme_is_not_http_or_https() {
|
|||
&DontConnectFactory,
|
||||
DEFAULT_USER_AGENT.to_owned(),
|
||||
&CancellationListener::new(None)) {
|
||||
Err(ref load_err) if load_err.error == LoadErrorType::UnsupportedScheme => (),
|
||||
Err(ref load_err) if load_err.error == LoadErrorType::UnsupportedScheme { scheme: "ftp".into() } => (),
|
||||
_ => panic!("expected ftp scheme to be unsupported")
|
||||
}
|
||||
}
|
||||
|
@ -1209,7 +1208,7 @@ fn test_load_errors_when_viewing_source_and_inner_url_scheme_is_not_http_or_http
|
|||
&DontConnectFactory,
|
||||
DEFAULT_USER_AGENT.to_owned(),
|
||||
&CancellationListener::new(None)) {
|
||||
Err(ref load_err) if load_err.error == LoadErrorType::UnsupportedScheme => (),
|
||||
Err(ref load_err) if load_err.error == LoadErrorType::UnsupportedScheme { scheme: "ftp".into() } => (),
|
||||
_ => panic!("expected ftp scheme to be unsupported")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue