Return 409 Conflict on submit type rule error

It's not a server error if a Prolog rule is broken (but a mistake by the
project owner who added this rule). Hence a broken Prolog rule should
not cause 500 Internal Server Errors.

This makes the handling of 'submit type rule error' consistent with the
handling of 'submit rule error' which is already treated as 409
Conflict.

Adapt the message of the exception that is thrown for 'submit type rule
error' so that it is consistent with the message of the exception that
is thrown in case of 'submit rule error' (see MergeOp#checkSubmitRule).

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ica8871268cd62937e7019064ef3ac021a292e1e6
diff --git a/java/com/google/gerrit/server/restapi/change/Mergeable.java b/java/com/google/gerrit/server/restapi/change/Mergeable.java
index 9b17ed6..cce8923 100644
--- a/java/com/google/gerrit/server/restapi/change/Mergeable.java
+++ b/java/com/google/gerrit/server/restapi/change/Mergeable.java
@@ -17,7 +17,6 @@
 import com.google.gerrit.common.data.SubmitTypeRecord;
 import com.google.gerrit.entities.Change;
 import com.google.gerrit.entities.PatchSet;
-import com.google.gerrit.exceptions.StorageException;
 import com.google.gerrit.extensions.client.SubmitType;
 import com.google.gerrit.extensions.common.MergeableInfo;
 import com.google.gerrit.extensions.restapi.AuthException;
@@ -133,10 +132,10 @@
     return Response.ok(result);
   }
 
-  private SubmitType getSubmitType(ChangeData cd) {
+  private SubmitType getSubmitType(ChangeData cd) throws ResourceConflictException {
     SubmitTypeRecord rec = submitRuleEvaluator.getSubmitType(cd);
     if (rec.status != SubmitTypeRecord.Status.OK) {
-      throw new StorageException("Submit type rule failed: " + rec);
+      throw new ResourceConflictException("submit type rule error: " + rec.errorMessage);
     }
     return rec.type;
   }