Skip to content

Commit

Permalink
fix: improves panic messages when there is no reactor/timer
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Jan 21, 2020
1 parent 5d82ac2 commit d480598
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tokio/src/io/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ impl Handle {
///
/// This function panics if there is no current reactor set.
pub(super) fn current() -> Self {
context::io_handle().expect("no current reactor")
context::io_handle().expect(
"there is no reactor running, this code must be executed from within a tokio runtime",
)
}

/// Forces a reactor blocked in a call to `turn` to wakeup, or otherwise
Expand Down
4 changes: 3 additions & 1 deletion tokio/src/time/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::Kind::*;
let descr = match self.0 {
Shutdown => "timer is shutdown",
Shutdown => {
"the timer is shutdown, this code must be executed from within a tokio runtime"
}
AtCapacity => "timer is at capacity and cannot create a new entry",
};
write!(fmt, "{}", descr)
Expand Down

0 comments on commit d480598

Please sign in to comment.