Created
January 10, 2017 23:38
-
-
Save lholden/1954655c075543d98cc9e9a890a20079 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use uuid; | |
use postgres; | |
use r2d2; | |
use std::num; | |
#[derive(Debug, Serialize)] | |
pub enum Error { | |
InvalidParam(String), | |
DatabaseError(String), | |
RecordNotFound(String), | |
RecordNotSaved, | |
} | |
impl From<num::ParseIntError> for Error { | |
fn from(err: num::ParseIntError) -> Self { | |
Error::InvalidParam(format!("{}", err)) | |
} | |
} | |
impl From<uuid::ParseError> for Error { | |
fn from(err: uuid::ParseError) -> Self { | |
Error::InvalidParam(format!("{}", err)) | |
} | |
} | |
impl From<postgres::error::Error> for Error { | |
fn from(err: postgres::error::Error) -> Self { | |
Error::DatabaseError(format!("{}", err)) | |
} | |
} | |
impl From<r2d2::GetTimeout> for Error { | |
fn from(err: r2d2::GetTimeout) -> Self { | |
Error::DatabaseError(format!("{}", err)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment