use of com.google.gerrit.server.project.NoSuchChangeException in project gerrit by GerritCodeReview.
the class GetContent method getMergeList.
private byte[] getMergeList(ChangeNotes notes) throws IOException {
Change.Id changeId = notes.getChangeId();
PatchSet ps = psUtil.current(notes);
if (ps == null) {
throw new NoSuchChangeException(changeId);
}
try (Repository git = gitManager.openRepository(notes.getProjectName());
RevWalk revWalk = new RevWalk(git)) {
return Text.forMergeList(ComparisonType.againstAutoMerge(), revWalk.getObjectReader(), ps.commitId()).getContent();
} catch (RepositoryNotFoundException e) {
throw new NoSuchChangeException(changeId, e);
}
}
use of com.google.gerrit.server.project.NoSuchChangeException 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);
}
Aggregations