Mark,
I think what they are asking for is a more graceful mechanism to handle
exceptions. E.g., the session would probably still be invalidated, but we
could provide more meaningful exception management, like isolating/reporting
the rule causing the problem, and eventually even allow for error recovery
(in case the user knows what he is doing), maybe removing the offending
rule. The accumulate returning null is another example of where we could use
such a mechanism.
I also think this would be good when we move to areas like
high-availability as we were discussing the other day.
I would say, lets investigate and maybe add some support for next feature
release (4.2 or whatever).
[]s
Edson
2007/8/24, Mark Proctor <mproctor(a)codehaus.org>:
if a rule throws an exception you can catch it from java land and create
your new session, we do not swallow excpetions.What we do though is wrap
them to RuntimeExceptions, so you would have to get out the nested exception
to see the real problem.
Beyond the above, I guess I don't understand what it is you are looking
for.
Mark
Yang Song wrote:
Thanks a lot for the answer, Mark. But I don't think it makes sense.
Because in some scenarios, you cannot guarantee the consequence part of
rule is 100% correct -- there could be errors happening in run-time which
are hard to predict, especially when a complex action or logic will be
executed as the concequece.
There should at least be some mechanisms to tell whoever fires the rule
that there is something wrong during the rule firing process, then and
he can do something, e.g. create a new session. Also it should enable
the rule firer to catch these exceptions and do the clean up work silently
-- instead of leaving these things on the stderr even cannot be seen in the
logs. This will make the program depending on the JBoss Rules to be more
robust.
What do you think? If JBoss Rules already has the ability to do this job,
can you please let me know?
Thanks again,
Yang
On 8/24/07, Mark Proctor <mproctor(a)codehaus.org> wrote:
>
> 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@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
------------------------------
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com