ChangesCollection: Return different text on multiple changes

Users are often confused when looking up a change just says "Not
found" when they are sure a change exists, but weren't aware that a
search returned multiple changes. Distinguish between these two cases
by changing the human-readable text in the response.

Change-Id: I87f6cd231be026e2bb48f26e18f11a5485aeb0e9
This commit is contained in:
Dave Borowitz
2015-12-07 15:49:04 -05:00
parent d42efe72a2
commit f78de90f37
2 changed files with 30 additions and 1 deletions

View File

@@ -92,9 +92,12 @@ public class ChangesCollection implements
}
}
}
if (ctls.size() != 1) {
if (ctls.isEmpty()) {
throw new ResourceNotFoundException(id);
}
if (ctls.size() != 1) {
throw new ResourceNotFoundException("Multiple changes found for " + id);
}
ChangeControl ctl = ctls.get(0);
if (!ctl.isVisible(db.get())) {