Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to stop RuleBook evaluations when exceptions are thrown? #78

Closed
jjzazuet opened this issue Jul 8, 2017 · 2 comments
Closed

Comments

@jjzazuet
Copy link

jjzazuet commented Jul 8, 2017

Hi. This is an awesome library!

Suppose the following:

  • I have a service call with side effects that can throw checked or unchecked exceptions at runtime (e.g. a database read/write call).
  • The method call is embedded as a then method on a rule evaluation.
  • If the service method fails (i.e. throws an Exception), the rule book evaluation continues to execute.

In my use case, is it possible to configure RuleBook or each individual rule in such a way that any unhandled Exceptions stop the rule book evaluation and have the Exception bubble up back to the caller? Is there a better way to handle this scenario?

Thanks again!

@Clayton7510
Copy link
Collaborator

As you pointed out, when an exception occurs the next rule is evaluated. There are a few reasons for this. One being that the idea was faulty rule logic that resulted in exceptions should not break the rule chain. The other one is that guarding against problems with rule creation becomes needed more when those rules are POJO rules - invalid method signatures or access restrictions could cause an error. So, the decision was made where rules that error are just discarded and the rule chain marches along.

Presently, you could catch the exceptions and handle them and then return RuleState.BREAK from the then method to stop the rule chain. I think that would be your best course of action.

@jjzazuet
Copy link
Author

OK cool will try that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants