diff options
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 10 | 
1 files changed, 10 insertions, 0 deletions
| diff --git a/src/error.rs b/src/error.rs index 41b4e64..1005564 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,6 +9,7 @@ use iron::modifiers::Header;  #[derive(Debug)]  pub enum LinoError {      DbError(rusqlite::Error), +    IoError(std::io::Error),      NotFound(String),      BadRequest(String),  } @@ -19,6 +20,7 @@ impl fmt::Display for LinoError {      fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {          match *self {              LinoError::DbError(ref err) => err.fmt(f), +            LinoError::IoError(ref err) => err.fmt(f),              LinoError::NotFound(ref x) => write!(f, "Could not find {}", x),              LinoError::BadRequest(ref x) => write!(f, "Bad request: {}", x),          } @@ -29,6 +31,7 @@ impl std::error::Error for LinoError {      fn description(&self) -> &str {          match *self {              LinoError::DbError(ref err) => err.description(), +            LinoError::IoError(ref err) => err.description(),              LinoError::NotFound(_) => "not found",              LinoError::BadRequest(_) => "bad request",          } @@ -37,6 +40,7 @@ impl std::error::Error for LinoError {      fn cause(&self) -> Option<&std::error::Error> {          match *self {              LinoError::DbError(ref err) => Some(err), +            LinoError::IoError(ref err) => Some(err),              LinoError::NotFound(_) => None,              LinoError::BadRequest(_) => None,          } @@ -49,6 +53,12 @@ impl From<rusqlite::Error> for LinoError {      }  } +impl From<std::io::Error> for LinoError { +    fn from(err: std::io::Error) -> LinoError { +        LinoError::IoError(err) +    } +} +  impl From<LinoError> for IronError {      fn from(err: LinoError) -> IronError {          let code = match err { | 
