RunError and few more error types implements Error (#501)

This allows them to be used with things like `failure`.
This commit is contained in:
Michal 'vorner' Vaner
2018-07-24 13:27:57 -07:00
committed by Carl Lerche
parent 365efec24a
commit 84db325628
2 changed files with 70 additions and 0 deletions
+17
View File
@@ -9,6 +9,8 @@ use tokio_executor;
use futures::Future;
use std::fmt;
use std::error::Error;
use std::io;
/// Single-threaded runtime provides a way to start reactor
@@ -48,6 +50,21 @@ pub struct RunError {
inner: current_thread::RunError,
}
impl fmt::Display for RunError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}", self.inner)
}
}
impl Error for RunError {
fn description(&self) -> &str {
self.inner.description()
}
fn cause(&self) -> Option<&Error> {
self.inner.cause()
}
}
impl Runtime {
/// Returns a new runtime initialized with default configuration values.
pub fn new() -> io::Result<Runtime> {