Don't treat MergeIdenticalTreeException as internal server error

MergeIdenticalTreeException as well as its derived class
ChangeAlreadyMergedException were previously interpreted as an internal
server error because no custom mapping existed for them in
RestApiServlet. Strangely, they inherited from RestApiException, which
we typically use to indicate that we handle such exceptions gracefully
(e.g. we return a proper error code and a message as explanation).

Both MergeIdenticalTreeException and ChangeAlreadyMergedException
actually indicate an internal conflict, which we typically represent by
a ResourceConflictException. By inheriting from
ResourceConflictException, we automatically get the mapping to a proper
error code. This is in line with MergeConflictException, which also
inherits from ResourceConflictException.

Change-Id: Ieacd730ccd0ab2efdb1b02b0556dd6117ab5f920
This commit is contained in:
Alice Kober-Sotzek 2018-02-21 11:11:44 +01:00 committed by David Pursehouse
parent be89feda85
commit 0f2faafdda
1 changed files with 2 additions and 2 deletions

View File

@ -14,13 +14,13 @@
package com.google.gerrit.server.git;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
/**
* Indicates that the commit is already contained in destination branch. Either the commit itself is
* in the source tree, or the content is merged
*/
public class MergeIdenticalTreeException extends RestApiException {
public class MergeIdenticalTreeException extends ResourceConflictException {
private static final long serialVersionUID = 1L;
/** @param msg message to return to the client describing the error. */