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:
@@ -38,7 +38,7 @@ fn timeout_closes_connection() {
|
||||
let url = format!("http://{}/closes", server.addr());
|
||||
let err = client.get(&url).send().unwrap_err();
|
||||
|
||||
assert_eq!(err.get_ref().unwrap().to_string(), "timed out");
|
||||
assert!(err.is_timeout());
|
||||
assert_eq!(err.url().map(|u| u.as_str()), Some(url.as_str()));
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ fn write_timeout_large_body() {
|
||||
.send()
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(err.get_ref().unwrap().to_string(), "timed out");
|
||||
assert!(err.is_timeout());
|
||||
assert_eq!(err.url().map(|u| u.as_str()), Some(url.as_str()));
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ fn test_response_timeout() {
|
||||
.send()
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(err.get_ref().unwrap().to_string(), "timed out");
|
||||
assert!(err.is_timeout());
|
||||
assert_eq!(err.url().map(|u| u.as_str()), Some(url.as_str()));
|
||||
}
|
||||
|
||||
@@ -158,5 +158,5 @@ fn test_read_timeout() {
|
||||
);
|
||||
|
||||
let err = res.text().unwrap_err();
|
||||
assert_eq!(err.to_string(), "timed out");
|
||||
assert!(err.is_timeout());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user