Commit 1998a580 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

cargo: migrate to error-chain

parent 35b07e59
......@@ -16,9 +16,9 @@ serde_codegen = "~0.8"
[dependencies]
chrono = { version = "~0.2", features = ["serde"] }
error-chain = "~0.7"
hyper = { version = "~0.9", default-features = false }
log = "~0.3"
quick-error = "~1.1"
reqwest = "~0.2"
serde = "~0.8"
serde_json = "~0.8"
......
......@@ -6,41 +6,26 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate reqwest;
use self::reqwest::Error as ReqwestError;
extern crate serde_json;
use self::serde_json::Error as SerdeError;
use self::serde_json::Value;
extern crate url;
use self::url::ParseError as UrlError;
quick_error! {
#[derive(Debug)]
/// Errors which may occur when communicating with Gitlab.
pub enum Error {
error_chain! {
errors {
/// Error occurred when communicating with Gitlab.
Reqwest(err: ReqwestError) {
cause(err)
display("reqwest error: {:?}", err)
from()
Communication {
display("communication error")
}
/// URL parsing error; should never occur.
UrlParse(err: UrlError) {
cause(err)
display("url error: {:?}", err)
from()
UrlParse {
display("url error")
}
/// Gitlab returned an error message.
Gitlab(err: String) {
display("gitlab error: {:?}", err)
Gitlab(msg: String) {
display("gitlab error: {}", msg)
}
/// Failed to deserialize a Gitlab result into a structure.
Deserialize(err: Box<SerdeError>) {
cause(err)
display("deserialization error: {:?}", err)
from()
Deserialize {
display("deserialization error")
}
}
}
......@@ -52,12 +37,6 @@ impl Error {
.and_then(|s| s.as_str())
.unwrap_or_else(|| "unknown error");
Error::Gitlab(msg.to_string())
}
}
impl From<SerdeError> for Error {
fn from(error: SerdeError) -> Self {
Error::Deserialize(Box::new(error))
Error::from_kind(ErrorKind::Gitlab(msg.to_string()))
}
}
This diff is collapsed.
......@@ -11,13 +11,13 @@
//! A library for communicating with Gitlab instances.
#[macro_use]
extern crate hyper;
extern crate error_chain;
#[macro_use]
extern crate log;
extern crate hyper;
#[macro_use]
extern crate quick_error;
extern crate log;
mod error;
#[macro_use]
......@@ -29,11 +29,10 @@ pub mod types;
pub mod webhooks;
pub mod hooks;
pub use error::Error;
pub use error::*;
pub use gitlab::CommitStatusInfo;
pub use gitlab::MergeRequestStateFilter;
pub use gitlab::Gitlab;
pub use gitlab::GitlabResult;
pub use types::*;
#[cfg(test)]
......
......@@ -46,13 +46,13 @@ macro_rules! enum_serialize {
}
impl Serialize for $name {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> ::std::result::Result<(), S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl Deserialize for $name {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> ::std::result::Result<Self, D::Error> {
let val = try!(String::deserialize(deserializer));
match val.as_str() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment