Message ID | 20180720115728.19312-4-ruscur@russell.cc |
---|---|
State | Accepted |
Headers | show |
Series | [1/8] Convert from hyper to reqwest | expand |
On 20/07/18 21:57, Russell Currey wrote: > Signed-off-by: Russell Currey <ruscur@russell.cc> This could probably do with a timeout... as could everything else in this function though, so: Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
diff --git a/src/jenkins.rs b/src/jenkins.rs index 0e7cdbc..987fae9 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -111,7 +111,14 @@ impl JenkinsBackend { let url = format!("{}api/json", base_url); let mut result_str = String::new(); loop { - let mut resp = self.get_url(&url).expect("HTTP request error"); + let mut resp = match self.get_url(&url) { + Ok(r) => r, + Err(e) => { + warn!("Couldn't hit Jenkins API: {}", e); + sleep(Duration::from_millis(JENKINS_POLLING_INTERVAL)); + continue; + } + }; if resp.status().is_server_error() { sleep(Duration::from_millis(JENKINS_POLLING_INTERVAL));
Signed-off-by: Russell Currey <ruscur@russell.cc> --- src/jenkins.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)