[rules-users] How to catch Exceptions when firing rules

Mark Proctor mproctor at codehaus.org
Fri Aug 24 06:58:56 EDT 2007


Once an exception is thrown on a conseuqence the current session is 
considered invalid. You'll need to add the try catch inside of the 
actual consequence.

Mark
Yang Song wrote:
> Hi,
>  
> Anyone knows how to catch the exception when firing the rules?
>  
> I wrapped the session.fireAllRules() method using try...catch, however 
> it doesn't work: when someone wrote bad code in the rule's action 
> part, the Exception will be thrown and printed to the stderr, and this 
> will make the rule engine stop working -- the try...catch outside 
> doesn't help anything.
>  
> If  the exception thrown from the rule's action part can be caught 
> externally, the system can be protected from interrupting Exception.
>
> try {
>         _log.debug("Firing rules in : " + getName());
>
>         session.fireAllRules();
>
> } catch (Exception e) {
>         _log.info("Error when firing rules: ", e);
> }
>
> Thanks,
> Yang
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070824/7410055b/attachment.html 


More information about the rules-users mailing list