As RequirementCollection is no longer a Requirement I was trying to get the result members as IResources:
for (IResource resource: result.getMembers(IResource.class)) {
if (resource instanceof Requirement) {
Requirement bean = (Requirement) resource;
Now I see this on the console:
java.lang.IllegalStateException: org.eclipse.lyo.oslc.domains.am.IResource
at org.eclipse.lyo.client.query.OslcQueryResult$1$1.next(OslcQueryResult.java:276)
Looking at OslcQueryResult.getMembers() I see this:
try {
return (T)JenaModelHelper.fromJenaResource((Resource)member.getObject(), clazz);
} catch (IllegalArgumentException e) {
throw new IllegalStateException(e.getMessage());
} catch (SecurityException e) {
throw new IllegalStateException(e.getMessage());
} catch (DatatypeConfigurationException e) {
throw new IllegalStateException(e.getMessage());
} catch (IllegalAccessException e) {
throw new IllegalStateException(e.getMessage());
} catch (InstantiationException e) {
throw new IllegalStateException(e.getMessage());
} catch (InvocationTargetException e) {
throw new IllegalStateException(e.getMessage());
} catch (OslcCoreApplicationException e) {
throw new IllegalStateException(e.getMessage());
} catch (URISyntaxException e) {
throw new IllegalStateException(e.getMessage());
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e.getMessage());
}
What’s the reason for swallowing all the interesting original exceptions and pretending they’re all IllegalStateExceptions?
And why is JenaModelHelper.fromJenaResource() deprecated? Where is the replacement functionality? Note that you can give such valuable information to your users via a JavaDoc annotation.
Blanket (incorrect) wrapping of the exceptions is bad, let’s continue in
As to why this was done, my guess is that in the old days there was no strategy for dealing with exceptions and every checked exception was bubbled up, causing a huge catch statement on every call plus no clear message cause. The way I do it is to define a Lyo specific exception and then wrap the thrown exception in it if I understand what is the possible cause of the underlying exception. For example,