From b309e7800d633000f4d0a1ae28a927378369b8ca Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 24 Jul 2015 15:23:57 +0200 Subject: [PATCH] Fix batch authentication error message --- .../main/java/org/sonar/batch/bootstrap/ServerClient.java | 4 ++-- .../src/main/java/org/sonar/batch/bootstrap/WSLoader.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java index 66e2677691f..b10f996f20f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java @@ -132,11 +132,11 @@ public class ServerClient { public RuntimeException handleHttpException(HttpDownloader.HttpException he) { if (he.getResponseCode() == 401) { - return new IllegalStateException(String.format(getMessageWhenNotAuthorized(), CoreProperties.LOGIN, CoreProperties.PASSWORD)); + return new IllegalStateException(String.format(getMessageWhenNotAuthorized(), CoreProperties.LOGIN, CoreProperties.PASSWORD), he); } if (he.getResponseCode() == 403) { // SONAR-4397 Details are in response content - return new IllegalStateException(tryParseAsJsonError(he.getResponseContent())); + return new IllegalStateException(tryParseAsJsonError(he.getResponseContent()), he); } return new IllegalStateException(String.format("Fail to execute request [code=%s, url=%s]", he.getResponseCode(), he.getUri()), he); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoader.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoader.java index d475e68c360..26246bc3d9a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoader.java @@ -123,9 +123,8 @@ public class WSLoader { if (e.getCause() instanceof HttpDownloader.HttpException) { throw e; } + throw new IllegalStateException(FAIL_MSG, e); } - - throw new IllegalStateException(FAIL_MSG); } @Nonnull @@ -141,9 +140,8 @@ public class WSLoader { if (cached != null) { return cached; } + throw new IllegalStateException(FAIL_MSG, serverException); } - - throw new IllegalStateException(FAIL_MSG); } private byte[] loadFromCache(String id) { -- 2.39.5