Implement reduce_to_string for InternalError
This can be used if the error needs send over a channel
and thus must be Send.
Box<dyn Error> is not Send.
@@ -126,6 +126,18 @@ impl InternalError {
source: None,
}
}
+
+ /// Reduces the `InternalError` to the display string
+ ///
+ /// If the error includes a source, the debug format will be logged to provide
+ /// information that may be lost on the conversion.
+ pub fn reduce_to_string(self) -> String {
+ if self.source.is_some() {
+ debug!("{:?}", self);
+ }
+
+ self.to_string()
+ }
}
impl error::Error for InternalError {
