From e4d6aaec0bebc7d3df0b9c03902cc2e283b6bbb2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 11 Nov 2017 21:11:51 +0100 Subject: github.rs: Add error handling with `Result` Return a `Result` from `update_commit_status()` to eliminate our `.unwrap()` calls. --- src/github.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/github.rs') 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, context: String, -) { +) -> Result<(), Box> { 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(()) } -- cgit v1.2.3