diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-07-10 10:31:23 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-07-10 10:31:23 -0400 |
commit | 15267c895e04f782aaae5fc7c24cd89d6db54f95 (patch) | |
tree | 779a4e13e26da4ace950249aadee1162640aa498 /src/error.rs | |
parent | 1cc4f17a742e0d0ef047842ac854e1d1ee8ec8b7 (diff) |
add: Page to add new quotes.
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 5 |
1 files changed, 5 insertions, 0 deletions
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<T> = std::result::Result<T, LinoError>; @@ -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<LinoError> 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); |