Enhance logging in entity locator factory
Enhanced logging to provide more detailed information when an entity
locator is not found, specifically distinguishing cases where a class is
missing due to unsupported parameter combinations from other exceptions.
Change-Id: I1ba84c622719c9b87c7f82966be24c9942ef3f07
Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/code/context/ondemand/locator/CodeLocatorFactory.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/code/context/ondemand/locator/CodeLocatorFactory.java
index a4e40d2..de3b042 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/code/context/ondemand/locator/CodeLocatorFactory.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/code/context/ondemand/locator/CodeLocatorFactory.java
@@ -59,9 +59,11 @@
entityLocator = clazz
.getDeclaredConstructor(Configuration.class, GerritChange.class, GitRepoFiles.class)
.newInstance(config, change, gitRepoFiles);
- } catch (ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException |
- NoSuchMethodException e) {
- log.warn("Entity locator `{}` class not found for Get-Context Item: {}", className, chatGptGetContextItem);
+ } catch (ClassNotFoundException e) {
+ log.warn("Entity locator class not found for Get-Context Item: {}", chatGptGetContextItem);
+ throw new CodeContextOnDemandLocatorException(e);
+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
+ log.error("Error instantiating class: {}", className, e);
throw new CodeContextOnDemandLocatorException(e);
}
return entityLocator;