Skip to content

Commit

Permalink
Exception handler for when a service cannot be loaded (#5667)
Browse files Browse the repository at this point in the history
feat: Exception handler for when a service cannot be loaded. Created as an inner class so logs can be suppressed if desired.
  • Loading branch information
filipelautert committed Mar 11, 2024
1 parent 2149ec9 commit 5e9919b
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ public <T> List<T> findInstances(Class<T> interfaceType) throws ServiceNotFoundE
log.fine("Loaded "+interfaceType.getName()+" instance "+service.getClass().getName());
allInstances.add(service);
} catch (Throwable e) {
log.info("Cannot load service", e);
new ServiceLoadExceptionHandler().handleException(e);
log.fine(e.getMessage(), e);
}
}

return Collections.unmodifiableList(allInstances);

}

/**
* Exception handler for when a service cannot be loaded. Created as an inner class so logs can be suppressed if desired.
*/
static class ServiceLoadExceptionHandler {
void handleException(Throwable e) {
Logger log = Scope.getCurrentScope().getLog(getClass());
log.info("Cannot load service", e);
}
}
}

0 comments on commit 5e9919b

Please sign in to comment.