Add a verbose error message for BlockingError (#451)

Add a verbose error message for EnterError while trying to run
tokio_threadpool::blocking on a current_thread::Runtime
This commit is contained in:
Roman
2018-06-26 08:37:48 -07:00
committed by Carl Lerche
parent 3fecd0154c
commit 24d99c029e
+8 -1
View File
@@ -6,7 +6,6 @@ use std::error::Error;
use std::fmt;
/// Error raised by `blocking`.
#[derive(Debug)]
pub struct BlockingError {
_p: (),
}
@@ -156,6 +155,14 @@ impl fmt::Display for BlockingError {
}
}
impl fmt::Debug for BlockingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("BlockingError")
.field("reason", &self.description())
.finish()
}
}
impl Error for BlockingError {
fn description(&self) -> &str {
"`blocking` annotation used from outside the context of a thread pool"