Add MalformedReducedToString error variant
This change adds the variant MalformedReducedToString to the
events::error::ParseError.  This allows an error that is not Send to
forward its information back to the caller.
@@ -20,12 +20,15 @@ use tokio::io;
#[derive(Debug)]
pub enum ParseError {
MalformedMessage(Box<dyn error::Error + Send + Sync + 'static>),
+ /// This type provides a sendable alternative to source errors that may not be Sync and Send.
+ MalformedReducedToString(String),
}
impl error::Error for ParseError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
ParseError::MalformedMessage(_) => None,
+ ParseError::MalformedReducedToString(_) => None,
}
}
}
@@ -34,6 +37,7 @@ impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ParseError::MalformedMessage(err) => write!(f, "Malformed message {}", err),
+ ParseError::MalformedReducedToString(msg) => f.write_str(&msg),
}
}
}
