summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index 523922a..7e68288 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -8,6 +8,8 @@ use std::fmt;
pub enum Error {
DieselError(DieselErr),
PasswordError(BcryptError),
+ CommunicationError(reqwest::Error),
+ ParseError(serde_json::error::Error),
AlreadyExists,
NotFound,
InternalError,
@@ -18,6 +20,8 @@ impl fmt::Display for Error {
match *self {
Error::DieselError(ref e) => e.fmt(f),
Error::PasswordError(ref e) => e.fmt(f),
+ Error::CommunicationError(ref e) => e.fmt(f),
+ Error::ParseError(ref e) => e.fmt(f),
Error::AlreadyExists => f.write_str("AlreadyExists"),
Error::NotFound => f.write_str("NotFound"),
Error::InternalError => f.write_str("InternalError"),
@@ -25,6 +29,18 @@ impl fmt::Display for Error {
}
}
+impl From<serde_json::error::Error> for Error {
+ fn from(e: serde_json::error::Error) -> Error {
+ Error::ParseError(e)
+ }
+}
+
+impl From<reqwest::Error> for Error {
+ fn from(e: reqwest::Error) -> Error {
+ Error::CommunicationError(e)
+ }
+}
+
impl From<DieselErr> for Error {
fn from(e: DieselErr) -> Error {
Error::DieselError(e)