aboutsummaryrefslogtreecommitdiff
path: root/src/error/mod.rs
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2022-10-21 21:20:51 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2022-10-21 21:20:51 +0200
commit434fb9531599a7bae55d8314f99773ee505492e7 (patch)
treea7c8b9d648aa074c9fc7f9b7fae4361c2c41aa9a /src/error/mod.rs
parentb346808516f3fe7d40ef389073a41583b32ef650 (diff)
making calls
Diffstat (limited to 'src/error/mod.rs')
-rw-r--r--src/error/mod.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs
index 8be0874..9c8bdfc 100644
--- a/src/error/mod.rs
+++ b/src/error/mod.rs
@@ -5,6 +5,11 @@ use std::fmt;
pub enum Error {
ParseUrl(url::ParseError),
Reqwest(reqwest::Error),
+ XmlRpc(xmlrpc::Error),
+ Inexistent(&'static str),
+ Type(&'static str, &'static str, xmlrpc::Value),
+ BadResponse(xmlrpc::Value),
+ BadStatus(&'static [i32], i32),
}
impl std::error::Error for Error {}
@@ -14,6 +19,20 @@ impl fmt::Display for Error {
match self {
Error::ParseUrl(err) => write!(fmt, "can't parse Url: {}", err),
Error::Reqwest(err) => write!(fmt, "reqwest error: {}", err),
+ Error::XmlRpc(err) => write!(fmt, "xmlrpc error: {}", err),
+ Error::Inexistent(what) => {
+ write!(fmt, "parameter {} does not exist", what)
+ }
+ Error::Type(what, exp, got) => {
+ write!(
+ fmt,
+ "parameter {what} is of wrong type {got:?} (expected: {exp})"
+ )
+ }
+ Error::BadResponse(resp) => write!(fmt, "bad response: {:?}", resp),
+ Error::BadStatus(expected, got) => {
+ write!(fmt, "bad status {} (expected: {:?}", got, expected)
+ }
}
}
}
@@ -30,5 +49,11 @@ impl From<reqwest::Error> for Error {
}
}
+impl From<xmlrpc::Error> for Error {
+ fn from(err: xmlrpc::Error) -> Self {
+ Self::XmlRpc(err)
+ }
+}
+
/// A `Result` alias where the `Err` case is `inwx::Error`.
pub type Result<T> = std::result::Result<T, Error>;