Skip to content

Commit

Permalink
error: remove StringError from Debug output
Browse files Browse the repository at this point in the history
Seeing `StringError("something something")` in debug output can cause
 someone to think there was an error dealing with `String`s, not that the
error type is just a string. So, remove that noise.
  • Loading branch information
seanmonstar committed May 17, 2019
1 parent 7d5aa43 commit d2d89b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libstd/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ impl From<String> for Box<dyn Error + Send + Sync> {
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
/// ```
fn from(err: String) -> Box<dyn Error + Send + Sync> {
#[derive(Debug)]
struct StringError(String);

impl Error for StringError {
Expand All @@ -313,6 +312,13 @@ impl From<String> for Box<dyn Error + Send + Sync> {
}
}

// Purposefully skip printing "StringError(..)"
impl Debug for StringError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Debug::fmt(&self.0, f)
}
}

Box::new(StringError(err))
}
}
Expand Down

0 comments on commit d2d89b1

Please sign in to comment.