refactor(error): improve error message when tokio::spawn fails

Closes #1635
This commit is contained in:
Sean McArthur
2018-10-16 15:14:06 -07:00
parent 12bc4cb485
commit c5e807715a
2 changed files with 36 additions and 10 deletions

View File

@@ -258,8 +258,8 @@ impl Error {
Error::new(Kind::Shutdown, Some(Box::new(cause)))
}
pub(crate) fn new_execute() -> Error {
Error::new(Kind::Execute, None)
pub(crate) fn new_execute<E: Into<Cause>>(cause: E) -> Error {
Error::new(Kind::Execute, Some(cause.into()))
}
pub(crate) fn new_h2(cause: ::h2::Error) -> Error {
@@ -269,10 +269,12 @@ impl Error {
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Error")
.field("kind", &self.inner.kind)
.field("cause", &self.inner.cause)
.finish()
let mut f = f.debug_struct("Error");
f.field("kind", &self.inner.kind);
if let Some(ref cause) = self.inner.cause {
f.field("cause", cause);
}
f.finish()
}
}