aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java3
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java3
2 files changed, 4 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
index d0abfb4bf92..8d9bacef6f5 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
@@ -30,6 +30,7 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
+import org.sonar.api.utils.MessageException;
import javax.annotation.CheckForNull;
import javax.persistence.*;
@@ -377,7 +378,7 @@ public class RulesProfile implements Cloneable {
return input.getRule().equals(rule);
}
})) {
- throw new IllegalStateException(String.format(
+ throw MessageException.of(String.format(
"The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.",
getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey()));
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java
index 79275aa2422..b13a38226da 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java
@@ -22,6 +22,7 @@ package org.sonar.api.profiles;
import org.junit.Test;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
+import org.sonar.api.utils.MessageException;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
@@ -71,7 +72,7 @@ public class RulesProfileTest {
profile.activateRule(rule, null);
fail();
} catch (Exception e) {
- assertThat(e).isInstanceOf(IllegalStateException.class)
+ assertThat(e).isInstanceOf(MessageException.class)
.hasMessage("The definition of the profile 'Default' (language 'java') contains multiple occurrences of the 'repo:key1' rule. The plugin which declares this profile should fix this.");
}
}