summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-11-20 13:25:00 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-11-20 16:51:47 +0100
commitfa7c92034236d9d282bbf4bac3af5802c4573ccd (patch)
treea37aaa62c486296122b80e4e08cec681ee1fa0bb /sonar-plugin-api
parent0a8c84057649c862014dd75241b5d72594363958 (diff)
downloadsonarqube-fa7c92034236d9d282bbf4bac3af5802c4573ccd.tar.gz
sonarqube-fa7c92034236d9d282bbf4bac3af5802c4573ccd.zip
SONAR-7037 Improve logging on authentication failure
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/MessageException.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/MessageException.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/MessageException.java
index 92ade0e1252..df4a6bd02a0 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/MessageException.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/MessageException.java
@@ -29,11 +29,17 @@ import static com.google.common.collect.Lists.newArrayList;
/**
* Runtime exception for "functional" error. It aims to be displayed to end-users, without any technical information
- * like stack traces. It requires sonar-runner 2.4. Previous versions log stack trace.
+ * like stack traces.
* <p/>
- * Note that by design Maven still logs the stack trace when the option -e is set.
+ *
+ * It's handling depends on the versions of the sonar-batch and sonar-runner. sonar-runner 2.4 will only show the
+ * message associated with this exception.
+ * Starting from sonar-batch 5.3, this is handled in the batch side, and the main goal is to hide all wrappers of this
+ * exception. If this exception is created without cause, then only the message associated with this exception is shown;
+ * otherwise, its causes are also shown.
+ * Previous combinations of sonar-batch/sonar-runner log all stack trace.
* <p/>
- * Message should be clear and complete. Keep in mind that context is not added to the exception.
+ * Message should be clear and complete. Keep in mind that context might not be added to the exception.
* Names of processed resource and decorator are for example not automatically added when throwing {@link MessageException}
* from {@link org.sonar.api.batch.Decorator}.
*
@@ -54,6 +60,16 @@ public class MessageException extends RuntimeException {
this.l10nParams = l10nParams == null ? Collections.emptyList() : Collections.unmodifiableCollection(newArrayList(l10nParams));
}
+ private MessageException(String message, Throwable cause) {
+ super(message, cause);
+ l10nKey = null;
+ l10nParams = Collections.emptyList();
+ }
+
+ public static MessageException of(String message, Throwable cause) {
+ return new MessageException(message, cause);
+ }
+
public static MessageException of(String message) {
return new MessageException(message);
}