Redesign Error type
- The `Error`'s kind is a now a set of variants depending on the context of when an error could occur. - If another error was the cause, it is now always the `source`. Along with the `is_*` methods, this should help in understanding *when* a certain error occurred. For example, an error setting the TLS certificates will return a builder error, with the TLS error as the source. This should help differentiate from a TLS error that happens when connecting to a server. It also makes the internal code less dependent on all the exact dependencies that can be enabled or disabled.
This commit is contained in:
@@ -270,8 +270,8 @@ fn test_error_for_status_4xx() {
|
||||
let url = format!("http://{}/1", server.addr());
|
||||
let res = reqwest::blocking::get(&url).unwrap();
|
||||
|
||||
let err = res.error_for_status().err().unwrap();
|
||||
assert!(err.is_client_error());
|
||||
let err = res.error_for_status().unwrap_err();
|
||||
assert!(err.is_status());
|
||||
assert_eq!(err.status(), Some(reqwest::StatusCode::BAD_REQUEST));
|
||||
}
|
||||
|
||||
@@ -299,8 +299,8 @@ fn test_error_for_status_5xx() {
|
||||
let url = format!("http://{}/1", server.addr());
|
||||
let res = reqwest::blocking::get(&url).unwrap();
|
||||
|
||||
let err = res.error_for_status().err().unwrap();
|
||||
assert!(err.is_server_error());
|
||||
let err = res.error_for_status().unwrap_err();
|
||||
assert!(err.is_status());
|
||||
assert_eq!(
|
||||
err.status(),
|
||||
Some(reqwest::StatusCode::INTERNAL_SERVER_ERROR)
|
||||
|
||||
Reference in New Issue
Block a user