From ae9f49152ef726dedea1ba5ce29517979ada7e51 Mon Sep 17 00:00:00 2001 From: Daniel Fly Date: Thu, 22 Jun 2017 13:46:44 +0200 Subject: Improved logging for thoubleshooting --- .../bitbucketpullrequestbuilder/bitbucket/ApiClient.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java index cb14908..cf3675c 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java @@ -256,8 +256,12 @@ public class ApiClient { client.getState().setCredentials(AuthScope.ANY, credentials); client.getParams().setAuthenticationPreemptive(true); try { - client.executeMethod(req); - return req.getResponseBodyAsString(); + int statusCode = client.executeMethod(req); + if (statusCode != HttpStatus.SC_OK) { + logger.log(Level.WARNING, "Response code failed: " + req.getStatusLine()); + }else{ + return req.getResponseBodyAsString(); + } } catch (HttpException e) { logger.log(Level.WARNING, "Failed to send request.", e); } catch (IOException e) { -- cgit v1.2.3