From 15267c895e04f782aaae5fc7c24cd89d6db54f95 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Mon, 10 Jul 2017 10:31:23 -0400 Subject: add: Page to add new quotes. --- src/error.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 649021e..3ccb73c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,6 +10,7 @@ use iron::modifiers::Header; pub enum LinoError { DbError(rusqlite::Error), NotFound(String), + BadRequest(String), } pub type Result = std::result::Result; @@ -19,6 +20,7 @@ impl fmt::Display for LinoError { match *self { LinoError::DbError(ref err) => err.fmt(f), LinoError::NotFound(ref x) => write!(f, "Could not find {}", x), + LinoError::BadRequest(ref x) => write!(f, "Bad request: {}", x), } } } @@ -28,6 +30,7 @@ impl std::error::Error for LinoError { match *self { LinoError::DbError(ref err) => err.description(), LinoError::NotFound(_) => "not found", + LinoError::BadRequest(_) => "bad request", } } @@ -35,6 +38,7 @@ impl std::error::Error for LinoError { match *self { LinoError::DbError(ref err) => Some(err), LinoError::NotFound(_) => None, + LinoError::BadRequest(_) => None, } } } @@ -49,6 +53,7 @@ impl From for IronError { fn from(err: LinoError) -> IronError { let code = match err { LinoError::NotFound(_) => status::NotFound, + LinoError::BadRequest(_) => status::BadRequest, _ => status::InternalServerError, }; let description = format!("{:?}", err); -- cgit v1.2.3