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:
@@ -27,7 +27,7 @@ impl PolyfillTryInto for Url {
|
||||
|
||||
impl<'a> PolyfillTryInto for &'a str {
|
||||
fn into_url(self) -> crate::Result<Url> {
|
||||
Url::parse(self).map_err(crate::error::from)?.into_url()
|
||||
Url::parse(self).map_err(crate::error::builder)?.into_url()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ mod tests {
|
||||
let err = "file:///etc/hosts".into_url().unwrap_err();
|
||||
assert_eq!(
|
||||
err.to_string(),
|
||||
"file:///etc/hosts: URL scheme is not allowed"
|
||||
"builder error for url (file:///etc/hosts): URL scheme is not allowed"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user