error: remove StringError from Debug output
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.
This commit is contained in:
@@ -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 {
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user