From 3d78fcbbb5af7eaf0aeef9b9c30a508ce44b4b08 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 22 Mar 2024 08:44:36 -0400 Subject: [PATCH] fix: Display for Error shouldn't include source (#2199) --- src/error.rs | 4 ---- src/into_url.rs | 9 +++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/error.rs b/src/error.rs index c558ebbac..12fca8b9c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -206,10 +206,6 @@ impl fmt::Display for Error { write!(f, " for url ({url})")?; } - if let Some(e) = &self.inner.source { - write!(f, ": {e}")?; - } - Ok(()) } } diff --git a/src/into_url.rs b/src/into_url.rs index a46ae5702..f1fdb49f7 100644 --- a/src/into_url.rs +++ b/src/into_url.rs @@ -84,13 +84,14 @@ if_hyper! { #[cfg(test)] mod tests { use super::*; + use std::error::Error; #[test] fn into_url_file_scheme() { let err = "file:///etc/hosts".into_url().unwrap_err(); assert_eq!( - err.to_string(), - "builder error for url (file:///etc/hosts): URL scheme is not allowed" + err.source().unwrap().to_string(), + "URL scheme is not allowed" ); } @@ -98,8 +99,8 @@ mod tests { fn into_url_blob_scheme() { let err = "blob:https://example.com".into_url().unwrap_err(); assert_eq!( - err.to_string(), - "builder error for url (blob:https://example.com): URL scheme is not allowed" + err.source().unwrap().to_string(), + "URL scheme is not allowed" ); }