Make NoSuchChangeException inherit from OrmException

More than a few throws and catch clauses already treat
NoSuchChangeException and OrmException identically; the few catch
clauses that actually care about the difference already catch
NoSuchChangeException explicitly. So this change results in a lot less
repeition.

The proximate reason for this change is I want to throw
NoSuchChangeException from ChangeNotes#load(), which is necessarily
called in a lot of places (because lazy-loading needs to be supported
when loading changes from the index with arbitrary
ListChangesOptions). Adding this new exception method is of course
possible but would have rippled out quite far.

The potential downside of this change is that authors of new code
calling a method that throws OrmException might not immediately know
that catching NoSuchChangeException is something they might want to
think about. However, I'm hoping this doesn't come up much in
practice; most callers should already have a loaded ChangeNotes or
similar object, so a NoSuchChangeException that late in the codepath
really is an unexpected error case.

Change-Id: Ibf28414344ebeeb4d37c28576feb14462e7c378a
This commit is contained in:
Dave Borowitz
2016-12-20 13:22:33 -05:00
parent e9070d639d
commit ba6b05d50c
30 changed files with 66 additions and 105 deletions

View File

@@ -84,7 +84,7 @@ public class GetContent implements RestReadView<FileResource> {
}
private String getMessage(ChangeNotes notes)
throws NoSuchChangeException, OrmException, IOException {
throws OrmException, IOException {
Change.Id changeId = notes.getChangeId();
PatchSet ps = psUtil.current(db.get(), notes);
if (ps == null) {
@@ -102,7 +102,7 @@ public class GetContent implements RestReadView<FileResource> {
}
private byte[] getMergeList(ChangeNotes notes)
throws NoSuchChangeException, OrmException, IOException {
throws OrmException, IOException {
Change.Id changeId = notes.getChangeId();
PatchSet ps = psUtil.current(db.get(), notes);
if (ps == null) {