diff options
| author | Teddy Wing | 2017-11-11 21:11:51 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-11-11 21:11:51 +0100 | 
| commit | e4d6aaec0bebc7d3df0b9c03902cc2e283b6bbb2 (patch) | |
| tree | 5d4bbd92a2fbded69046cf9150c35ec9ae59c492 /src | |
| parent | 47cd439b69c4c19074e6056d299eb704c375727b (diff) | |
| download | kipper-e4d6aaec0bebc7d3df0b9c03902cc2e283b6bbb2.tar.bz2 | |
github.rs: Add error handling with `Result`
Return a `Result` from `update_commit_status()` to eliminate our
`.unwrap()` calls.
Diffstat (limited to 'src')
| -rw-r--r-- | src/github.rs | 10 | 
1 files changed, 6 insertions, 4 deletions
| diff --git a/src/github.rs b/src/github.rs index de4f602..f24d1f0 100644 --- a/src/github.rs +++ b/src/github.rs @@ -2,6 +2,7 @@ extern crate mockito;  extern crate reqwest;  use std::collections::HashMap; +use std::error::Error;  use std::fmt;  use self::reqwest::header::{Accept, Authorization, Bearer, qitem}; @@ -38,7 +39,7 @@ pub fn update_commit_status(      target_url: String,      description: Option<String>,      context: String, -) { +) -> Result<(), Box<Error>> {      let client = reqwest::Client::new();      let mut params = HashMap::new(); @@ -61,7 +62,7 @@ pub fn update_commit_status(          )          .header(              Accept( -                vec![qitem("application/vnd.github.v3+json".parse().unwrap())] +                vec![qitem("application/vnd.github.v3+json".parse()?)]              )          )          .header( @@ -72,8 +73,9 @@ pub fn update_commit_status(              )          )          .json(¶ms) -        .send() -        .unwrap(); +        .send()?; + +    Ok(())  } | 
