Commit 5d7fba48 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'remove-error-chain'

d13b351a

 error-chain: remove in preference for `thiserror`
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !170
parents b7d26e10 d13b351a
......@@ -17,8 +17,9 @@ itertools = "~0.8"
log = "~0.4"
percent-encoding = "^2.0"
reqwest = "~0.9"
rustversion = "^1.0"
thiserror = "^1.0.2"
chrono = { version = "~0.4", features = ["serde"] }
error-chain = ">= 0.9, < 0.11"
serde = { version = "~1.0", features = ["derive"] }
serde_json = "^1.0"
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crates::reqwest;
use crates::serde_json::Value;
error_chain! {
foreign_links {
Reqwest(reqwest::Error)
#[doc = "An error from the reqwest crate."];
}
errors {
/// Error occurred when communicating with Gitlab.
Communication {
display("communication error")
}
/// Header value parsing error; should never occur.
HeaderValueParse {
display("header value error")
}
/// URL parsing error; should never occur.
UrlParse {
display("url error")
}
/// Gitlab returned an error message.
Gitlab(msg: String) {
display("gitlab error: {}", msg)
}
/// Failed to deserialize a Gitlab result into a structure.
Deserialize {
display("deserialization error")
}
}
}
impl Error {
/// Extract the message from a Gitlab JSON error.
pub fn from_gitlab(value: Value) -> Self {
let msg = value
.pointer("/message")
.or_else(|| value.pointer("/error"))
.and_then(|s| s.as_str())
.unwrap_or_else(|| "unknown error");
Error::from_kind(ErrorKind::Gitlab(msg.into()))
}
}
This diff is collapsed.
......@@ -8,16 +8,12 @@
//! A library for communicating with Gitlab instances.
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
mod crates {
// public
pub extern crate chrono;
// pub extern crate error_chain;
pub extern crate serde;
pub extern crate serde_json;
......@@ -26,9 +22,10 @@ mod crates {
pub extern crate log;
pub extern crate percent_encoding;
pub extern crate reqwest;
// pub extern crate rustversion;
pub extern crate thiserror;
}
mod error;
#[macro_use]
mod macros;
mod gitlab;
......@@ -38,11 +35,12 @@ pub mod systemhooks;
pub mod types;
pub mod webhooks;
pub use error::*;
pub use gitlab::CommitStatusInfo;
pub use gitlab::Gitlab;
pub use gitlab::GitlabBuilder;
pub use gitlab::GitlabError;
pub use gitlab::MergeRequestStateFilter;
pub use gitlab::TokenError;
pub use types::*;
#[cfg(test)]
......
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