Skip to content

Commit

Permalink
handleExceptionDuringValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Feb 5, 2024
1 parent 6e88110 commit ff95eac
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ private boolean isAssociatedToSource(EObject e) {
}

protected void checkJvmGenericType(JvmGenericType type) {
checkSuperTypes(type);
handleExceptionDuringValidation(() -> checkSuperTypes(type));
type.getDeclaredFields().forEach(field -> {
if (isAssociatedToSource(field))
checkField(field);
handleExceptionDuringValidation(() -> checkField(field));
});
checkJvmGenericTypes(type.getMembers());
handleExceptionDuringValidation(() -> checkJvmGenericTypes(type.getMembers()));
}

protected void checkSuperTypes(JvmGenericType type) {
Expand Down Expand Up @@ -223,4 +223,18 @@ else if (typeRef instanceof JvmParameterizedTypeReference) {
protected EStructuralFeature getFeatureForIssue(EObject object) {
return object.eClass().getEStructuralFeature("name");
}

/**
* When the {@link AbstractDeclarativeValidator} executes {@link Check} methods,
* it swallows some runtime exceptions so that other methods can be executed.
* In this class we only have a {@link Check} method that calls other methods, so for th
* other methods we simulate the same behavior.
*/
protected void handleExceptionDuringValidation(Runnable code) {
try {
code.run();
} catch (Throwable e) {
handleExceptionDuringValidation(e);
}
}
}

0 comments on commit ff95eac

Please sign in to comment.