NoteDbChecksUpdate: Improve error messages and make them consistent
* From a "foo:bar missing" message it's not clear that this is about a
checker.
* Most messages use "not found" instead of "missing"
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Idb6f106f74dc887c31561f8c7a170798e7b9f686
diff --git a/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java b/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java
index 87fb008..cb57c79 100644
--- a/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java
@@ -202,7 +202,9 @@
private void assertCheckerIsPresent(CheckerUuid checkerUuid)
throws ConfigInvalidException, IOException {
- checkers.getChecker(checkerUuid).orElseThrow(() -> new IOException(checkerUuid + " missing"));
+ checkers
+ .getChecker(checkerUuid)
+ .orElseThrow(() -> new IOException(String.format("checker %s not found", checkerUuid)));
}
private boolean updateNotesMap(
@@ -217,7 +219,7 @@
throws ConfigInvalidException, IOException, OrmDuplicateKeyException {
Ref patchSetRef = repo.exactRef(checkKey.patchSet().toRefName());
if (patchSetRef == null) {
- throw new IOException("patchset " + checkKey.patchSet() + " not found");
+ throw new IOException(String.format("patchset %s not found", checkKey.patchSet()));
}
RevId revId = new RevId(patchSetRef.getObjectId().name());
@@ -225,7 +227,7 @@
Map<RevId, NoteDbCheckMap> newNotes = getRevisionNoteByRevId(rw, curr);
if (!newNotes.containsKey(revId)) {
if (operation == Operation.UPDATE) {
- throw new IOException("Not found: " + checkKey.checkerUuid());
+ throw new IOException(String.format("checker %s not found", checkKey.checkerUuid()));
}
newNotes.put(revId, NoteDbCheckMap.empty());
@@ -234,7 +236,7 @@
NoteDbCheckMap checksForRevision = newNotes.get(revId);
if (!checksForRevision.checks.containsKey(checkKey.checkerUuid().get())) {
if (operation == Operation.UPDATE) {
- throw new IOException("Not found: " + checkKey.checkerUuid());
+ throw new IOException(String.format("checker %s not found", checkKey.checkerUuid()));
}
// Create check
@@ -245,7 +247,8 @@
writeNotesMap(newNotes, cb, ins);
return true;
} else if (operation == Operation.CREATE) {
- throw new OrmDuplicateKeyException(checkKey.checkerUuid() + " exists");
+ throw new OrmDuplicateKeyException(
+ String.format("checker %s already exists", checkKey.checkerUuid()));
}
// Update in place