Search in sources :

Example 1 with NoSuchRefException

use of com.google.gerrit.server.project.NoSuchRefException in project gerrit by GerritCodeReview.

the class BatchUpdate method wrapAndThrowException.

private static void wrapAndThrowException(Exception e) throws UpdateException, RestApiException {
    // exception types.
    if (e instanceof InvalidChangeOperationException || e instanceof LimitExceededException) {
        throw new ResourceConflictException(e.getMessage(), e);
    } else if (e instanceof NoSuchChangeException || e instanceof NoSuchRefException || e instanceof NoSuchProjectException) {
        throw new ResourceNotFoundException(e.getMessage(), e);
    } else if (e instanceof CommentsRejectedException) {
        // status code and it's isolated in monitoring.
        throw new BadRequestException(e.getMessage(), e);
    }
    Throwables.throwIfUnchecked(e);
    // Propagate REST API exceptions thrown by operations; they commonly throw exceptions like
    // ResourceConflictException to indicate an atomic update failure.
    Throwables.throwIfInstanceOf(e, UpdateException.class);
    Throwables.throwIfInstanceOf(e, RestApiException.class);
    // Otherwise, wrap in a generic UpdateException, which does not include a user-visible message.
    throw new UpdateException(e);
}
Also used : InvalidChangeOperationException(com.google.gerrit.server.project.InvalidChangeOperationException) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) NoSuchChangeException(com.google.gerrit.server.project.NoSuchChangeException) NoSuchProjectException(com.google.gerrit.server.project.NoSuchProjectException) NoSuchRefException(com.google.gerrit.server.project.NoSuchRefException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) LimitExceededException(com.google.gerrit.server.notedb.LimitExceededException) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Aggregations

BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 LimitExceededException (com.google.gerrit.server.notedb.LimitExceededException)1 InvalidChangeOperationException (com.google.gerrit.server.project.InvalidChangeOperationException)1 NoSuchChangeException (com.google.gerrit.server.project.NoSuchChangeException)1 NoSuchProjectException (com.google.gerrit.server.project.NoSuchProjectException)1 NoSuchRefException (com.google.gerrit.server.project.NoSuchRefException)1