Skip to content

Commit

Permalink
Better error catching for non comparables in event condition and adde…
Browse files Browse the repository at this point in the history
…d NPE protection when left or right side of evend conditions are null
  • Loading branch information
andsel committed Jul 24, 2024
1 parent 363d385 commit 32cec8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,13 @@ private static String getUnexpectedTypeDetails(Object unexpected) {
details = (expression.getSourceWithMetadata() != null) ? expression.getSourceWithMetadata().toString()
: expression.toString();
} else {
details = unexpected.toString();
if (unexpected == null) {
details = "<null-value>";
} else {
details = unexpected.toString();
}
}
return String.format("%s:%s", unexpected.getClass(), details);
return String.format("%s:%s", unexpected == null ? "<no-class>" : unexpected.getClass(), details);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void filterEvents(Collection<JrubyEventExtLibrary.RubyEvent> input
boolean isFulfilled;
try {
isFulfilled = filter.fulfilled(e);
} catch (org.jruby.exceptions.TypeError ex) {
} catch (org.jruby.exceptions.TypeError | IllegalArgumentException ex) {
// in case of error evaluation of an if condition, cancel the event
e.getEvent().cancel();
throw new ConditionalEvaluationError(ex, e.getEvent());
Expand Down

0 comments on commit 32cec8b

Please sign in to comment.