ChecksImpl#id(CheckerUuid): Fix error message when check is not found
The exising error message "Not found: <checker-UUID>" suggests that the
checker was not found. However this is never the case since the first
line in ChecksImpl#id(CheckerUuid) ensures that the checker exists.
Change-Id: I6b8d03d428310bdc945fc4e7b8f7750d62c08788
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/plugins/checks/api/ChecksImpl.java b/java/com/google/gerrit/plugins/checks/api/ChecksImpl.java
index 2a42c5f..361efe0 100644
--- a/java/com/google/gerrit/plugins/checks/api/ChecksImpl.java
+++ b/java/com/google/gerrit/plugins/checks/api/ChecksImpl.java
@@ -71,7 +71,14 @@
return checkApiImplFactory.create(
new CheckResource(
revisionResource,
- check.orElseThrow(() -> new ResourceNotFoundException("Not found: " + checkerUuid))));
+ check.orElseThrow(
+ () ->
+ new ResourceNotFoundException(
+ String.format(
+ "Patch set %s in project %s doesn't have check for checker %s.",
+ revisionResource.getPatchSet().getId(),
+ revisionResource.getProject(),
+ checkerUuid)))));
} catch (Exception e) {
throw asRestApiException("Cannot parse check", e);
}
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java
index 2df195b..d16e850 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/GetCheckIT.java
@@ -57,7 +57,10 @@
checkOperations.newCheck(checkKey).setState(CheckState.RUNNING).upsert();
exception.expect(ResourceNotFoundException.class);
- exception.expectMessage("Not found: " + checkerUuid);
+ exception.expectMessage(
+ String.format(
+ "Patch set %s in project %s doesn't have check for checker %s.",
+ patchSetId, project, checkerUuid));
checksApiFactory.revision(patchSetId).id(checkerUuid);
}
@@ -73,7 +76,10 @@
checkerOperations.checker(checkerUuid).forUpdate().disable().update();
exception.expect(ResourceNotFoundException.class);
- exception.expectMessage("Not found: " + checkerUuid);
+ exception.expectMessage(
+ String.format(
+ "Patch set %s in project %s doesn't have check for checker %s.",
+ patchSetId, project, checkerUuid));
checksApiFactory.revision(patchSetId).id(checkerUuid);
}