From b9d225974d9be1ded1ee0b47d8025916edd5736c Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 11 Nov 2017 22:49:04 +0100 Subject: find_and_track_build_and_update_status(): Use `Result`s Catch `Result` errors in the spawned thread by panicking with `expect`. Couldn't figure out how to use `expect` with a custom value, in the case of `request_job`. --- src/jenkins.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/jenkins.rs b/src/jenkins.rs index 5ee36de..024f7f7 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -102,7 +102,7 @@ pub fn find_and_track_build_and_update_status(commit_ref: CommitRef) job_url.clone(), None, "continuous-integration/jenkins".to_string() - ); + ).expect("GitHub pending status update failed."); while job.result == JobStatus::Pending { // loop @@ -122,14 +122,18 @@ pub fn find_and_track_build_and_update_status(commit_ref: CommitRef) job_url.clone(), Some("The status checker timed out.".to_string()), "continuous-integration/jenkins".to_string() - ); + ).expect("GitHub timeout error status update failed."); return } sleep(Duration::from_secs(30)); - let updated_job = request_job(job_url.as_ref()).unwrap(); + let updated_job = request_job( + job_url.as_ref() + ).expect( + format!("Failed to request job '{}'.", job_url).as_ref() + ); if job.result != updated_job.result { github::update_commit_status( @@ -138,7 +142,7 @@ pub fn find_and_track_build_and_update_status(commit_ref: CommitRef) job_url.clone(), None, "continuous-integration/jenkins".to_string() - ); + ).expect("GitHub status update failed."); return } -- cgit v1.2.3