use crates::reqwest;
use crates::serde_json::Value;
error_chain! {
foreign_links {
Reqwest(reqwest::Error)
#[doc = "An error from the reqwest crate."];
}
errors {
Communication {
display("communication error")
}
UrlParse {
display("url error")
}
Gitlab(msg: String) {
display("gitlab error: {}", msg)
}
Deserialize {
display("deserialization error")
}
}
}
impl Error {
pub fn from_gitlab(value: Value) -> Self {
let msg = value.pointer("/message")
.and_then(|s| s.as_str())
.unwrap_or_else(|| "unknown error");
Error::from_kind(ErrorKind::Gitlab(msg.to_string()))
}
}