fix(construct): Improve error messages occuring during Tweed construction

This commit is contained in:
2025-12-14 15:04:14 +01:00
parent 1e4ee118a9
commit f5c8b1aa50

View File

@@ -41,13 +41,17 @@ public class TweedConstructFactoryImpl<T> implements TweedConstructFactory<T> {
} }
private <C extends T> ConstructTarget<C> getConstructTarget(Class<C> type) { private <C extends T> ConstructTarget<C> getConstructTarget(Class<C> type) {
ConstructTarget<C> cachedConstructTarget = readConstructTargetFromCache(type); try {
if (cachedConstructTarget != null) { ConstructTarget<C> cachedConstructTarget = readConstructTargetFromCache(type);
return cachedConstructTarget; if (cachedConstructTarget != null) {
return cachedConstructTarget;
}
ConstructTarget<C> constructTarget = locateConstructTarget(type);
cacheConstructTarget(type, constructTarget);
return constructTarget;
} catch (Exception e) {
throw new RuntimeException("Failed to locate construct target for " + type.getName(), e);
} }
ConstructTarget<C> constructTarget = locateConstructTarget(type);
cacheConstructTarget(type, constructTarget);
return constructTarget;
} }
@Locked.Read("cachedConstructTargetsLock") @Locked.Read("cachedConstructTargetsLock")