diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-08-16 17:46:06 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-08-16 17:46:06 +0200 |
commit | 3125bcc453e3973298b7cf417b9ea8a158ba3b8a (patch) | |
tree | b0a5838b76870f46469310aff5ab5138d174eb72 /sonar-batch | |
parent | 906c2b413615c37ead1371bb1422be4c733747fd (diff) | |
download | sonarqube-3125bcc453e3973298b7cf417b9ea8a158ba3b8a.tar.gz sonarqube-3125bcc453e3973298b7cf417b9ea8a158ba3b8a.zip |
SONAR-4547 improve support of MessageException
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java | 8 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java index 26f0f425015..6fe7394e040 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java @@ -59,21 +59,21 @@ public class DatabaseCompatibility implements BatchComponent { message.append(" / *****)\n\t- Server side: check the configuration at "); message.append(server.getURL()); message.append("/system\n"); - throw new MessageException(message.toString()); + throw MessageException.of(message.toString()); } } private void checkDatabaseStatus() { DatabaseVersion.Status status = version.getStatus(); if (status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) { - throw new MessageException("Database relates to a more recent version of SonarQube. Please check your settings (JDBC settings, version of Maven plugin)"); + throw MessageException.of("Database relates to a more recent version of SonarQube. Please check your settings (JDBC settings, version of Maven plugin)"); } if (status == DatabaseVersion.Status.REQUIRES_UPGRADE) { - throw new MessageException("Database must be upgraded. Please browse " + server.getURL() + "/setup"); + throw MessageException.of("Database must be upgraded. Please browse " + server.getURL() + "/setup"); } if (status != DatabaseVersion.Status.UP_TO_DATE) { // Support other future values - throw new MessageException("Unknown database status: " + status); + throw MessageException.of("Unknown database status: " + status); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java index 7d77355ef11..539fc1e4529 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java @@ -27,6 +27,7 @@ import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.SonarIndex; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; +import org.sonar.api.utils.MessageException; import org.sonar.api.utils.SonarException; import org.sonar.batch.DecoratorsSelector; import org.sonar.batch.DefaultDecoratorContext; @@ -80,6 +81,9 @@ public class DecoratorsExecutor implements BatchComponent { decorator.decorate(resource, context); eventBus.fireEvent(new DecoratorExecutionEvent(decorator, false)); + } catch (MessageException e) { + throw e; + } catch (Exception e) { // SONAR-2278 the resource should not be lost in exception stacktrace. throw new SonarException("Fail to decorate '" + resource + "'", e); |