mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
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.
This commit is contained in:
parent
b853383afc
commit
2675d9d1ff
2 changed files with 64 additions and 43 deletions
|
@ -1076,8 +1076,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")
|
||||
}
|
||||
}
|
||||
|
@ -1167,7 +1166,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() }))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1185,7 +1184,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")
|
||||
}
|
||||
}
|
||||
|
@ -1204,7 +1203,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