From 24d99c029eff5d5b82aff567f1ad5ede8a8c2576 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 26 Jun 2018 19:37:48 +0400 Subject: [PATCH] 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 --- tokio-threadpool/src/blocking.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tokio-threadpool/src/blocking.rs b/tokio-threadpool/src/blocking.rs index c224f9e01..d75ed13ea 100644 --- a/tokio-threadpool/src/blocking.rs +++ b/tokio-threadpool/src/blocking.rs @@ -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"