Skip to content

Commit

Permalink
fix: Display for Error shouldn't include source (#2199)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar authored Mar 22, 2024
1 parent c535724 commit 3d78fcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/into_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,23 @@ 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"
);
}

#[test]
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"
);
}

Expand Down

0 comments on commit 3d78fcb

Please sign in to comment.