From e7ef11cbd0528ae9046ecfffcdb2fef7a8f05976 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Tue, 17 Jan 2017 16:17:34 -0500
Subject: [PATCH] cargo: remove use of quick-error

Just use strings instead. Using error-chain doesn't work since the
`Send` trait is not implemented for `Box<Error>` in general. All of
these errors end up bubbling directly to the top-level, so this
shouldn't be too much of an issue.
---
 src/config/checks.rs.in | 15 ++-------------
 src/config/types.rs     | 27 +++++++++------------------
 src/handlers/mod.rs     | 13 ++-----------
 src/main.rs             |  3 ---
 4 files changed, 13 insertions(+), 45 deletions(-)

diff --git a/src/config/checks.rs.in b/src/config/checks.rs.in
index aa997374..22a9bf83 100644
--- a/src/config/checks.rs.in
+++ b/src/config/checks.rs.in
@@ -24,20 +24,11 @@ use super::defaults;
 
 use std::error::Error;
 
-quick_error! {
-    #[derive(Debug)]
-    enum CheckError {
-        NoSuchCheck(check: String) {
-            display("unknown check: {}", check)
-        }
-    }
-}
-
 macro_rules! checks {
     { $req_name:expr, $req_config:expr, $( $name:expr => $config:ty, $kind:ident, )+ } => {
         match $req_name {
-            $( $name => $kind.push(try!(serde_json::from_value::<$config>($req_config)).into_check()), )*
-            _ => return Err(Box::new(CheckError::NoSuchCheck($req_name.to_string()))),
+            $( $name => Ok($kind.push(try!(serde_json::from_value::<$config>($req_config)).into_check())), )*
+            _ => Err(format!("unknown check: {}", $req_name).into()),
         }
     }
 }
@@ -67,8 +58,6 @@ pub fn create_check(name: &str, config: Value, checks: &mut Vec<Box<Check>>,
         "third_party" => ThirdPartyConfig, checks,
         "valid_name" => ValidNameConfig, checks,
     }
-
-    Ok(())
 }
 
 #[derive(Deserialize, Debug)]
diff --git a/src/config/types.rs b/src/config/types.rs
index baa80d84..d805d7be 100644
--- a/src/config/types.rs
+++ b/src/config/types.rs
@@ -102,20 +102,11 @@ pub struct Host {
     pub webhook_url: Option<String>,
 }
 
-quick_error! {
-    #[derive(Debug)]
-    enum HostError {
-        NoMaintainers {
-            display("no maintainers given")
-        }
-    }
-}
-
 impl Host {
     fn new(host: io::Host, service: Rc<HostingService>, workdir: PathBuf)
            -> Result<Self, Box<Error>> {
         if host.maintainers.is_empty() {
-            return Err(Box::new(HostError::NoMaintainers));
+            return Err("no maintainers were specified".into());
         }
 
         let project_workdir = workdir.join("projects");
@@ -190,11 +181,11 @@ impl Project {
                 let merge_checks =
                     try!(Checks::new(branch.merge_checks.iter().chain(project_checks.iter())));
 
-                let mut cbranch = try!(Branch::new(&branch_name,
-                                                   checks,
-                                                   merge_checks,
-                                                   context.clone(),
-                                                   identity.clone()));
+                let mut cbranch = Branch::new(&branch_name,
+                                              checks,
+                                              merge_checks,
+                                              context.clone(),
+                                              identity.clone());
 
                 if let Some(ref merge) = branch.merge {
                     let hosted_project = HostedProject {
@@ -467,8 +458,8 @@ pub struct Branch {
 impl Branch {
     fn new(name: &str, checks: Checks, merge_checks: Checks, context: GitContext,
            identity: Identity)
-           -> Result<Self, Box<Error>> {
-        Ok(Branch {
+           -> Self {
+        Branch {
             name: name.to_string(),
 
             checks: checks,
@@ -479,7 +470,7 @@ impl Branch {
 
             merge: None,
             stage: None,
-        })
+        }
     }
 
     fn add_merge(&mut self, merge_conf: &io::Merge, project: HostedProject)
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index aae70c89..aed7bb5e 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -25,21 +25,12 @@ use super::config::Host;
 use std::error::Error;
 use std::rc::Rc;
 
-quick_error! {
-    #[derive(Debug)]
-    enum HandlerError {
-        UnknownApi(api: String) {
-            display("unknown api: {}", api)
-        }
-    }
-}
-
 /// Connect to a `HostingService`.
 pub fn connect_to_host(api: &str, url: &Option<String>, secrets: Value)
                        -> Result<Rc<HostingService>, Box<Error>> {
     match api {
         "gitlab" => gitlab::connect_to_host(url, secrets),
-        _ => Err(Box::new(HandlerError::UnknownApi(api.to_string()))),
+        _ => Err(format!("unknown api: {}", api).into()),
     }
 }
 
@@ -47,6 +38,6 @@ pub fn connect_to_host(api: &str, url: &Option<String>, secrets: Value)
 pub fn create_handler(host: Host, name: &str) -> Result<Box<Handler>, Box<Error>> {
     match host.api.as_str() {
         "gitlab" => gitlab::create_handler(host, name),
-        _ => Err(Box::new(HandlerError::UnknownApi(host.api))),
+        _ => Err(format!("unknown api: {}", host.api).into()),
     }
 }
diff --git a/src/main.rs b/src/main.rs
index a06827d5..6ce14ae0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -30,9 +30,6 @@ extern crate lazy_static;
 extern crate log;
 use log::LogLevel;
 
-#[macro_use]
-extern crate quick_error;
-
 extern crate systemd;
 use systemd::journal::JournalLog;
 
-- 
GitLab