aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-01-07 10:45:31 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2013-01-07 10:45:31 +0100
commiteb4a343f2252588057f9d5e86f5382a270ed1a69 (patch)
tree5bbe51b211fe51897bdd628b0fb346e22da0fb8e /src/main/java
parentcac44f8d254c5fd5a1d01246a8db7d89aead26a2 (diff)
downloadsonar-scanner-cli-eb4a343f2252588057f9d5e86f5382a270ed1a69.tar.gz
sonar-scanner-cli-eb4a343f2252588057f9d5e86f5382a270ed1a69.zip
SONARPLUGINS-2468 Improve the error message when the bootstrapper fails to connect to server
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/sonar/runner/Bootstrapper.java4
-rw-r--r--src/main/java/org/sonar/runner/Logs.java6
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/sonar/runner/Bootstrapper.java b/src/main/java/org/sonar/runner/Bootstrapper.java
index 63fdad5..d201f47 100644
--- a/src/main/java/org/sonar/runner/Bootstrapper.java
+++ b/src/main/java/org/sonar/runner/Bootstrapper.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@@ -74,6 +75,9 @@ class Bootstrapper {
if (serverVersion == null) {
try {
serverVersion = remoteContent(VERSION_PATH);
+ } catch (ConnectException e) {
+ Logs.error("Sonar server '" + serverUrl + "' can not be reached");
+ throw new IllegalStateException("Fail to request server version", e);
} catch (IOException e) {
throw new IllegalStateException("Fail to request server version", e);
}
diff --git a/src/main/java/org/sonar/runner/Logs.java b/src/main/java/org/sonar/runner/Logs.java
index b0ad8c0..3ce1cca 100644
--- a/src/main/java/org/sonar/runner/Logs.java
+++ b/src/main/java/org/sonar/runner/Logs.java
@@ -24,6 +24,10 @@ final class Logs {
}
static void info(String message) {
- System.out.println(message); // NOSONAR
+ System.out.println(message);
+ }
+
+ static void error(String message) {
+ System.err.println("ERROR: " + message);
}
}