<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=801413315-24082007><FONT face=Arial 
color=#0000ff size=2>For what it's worth I think this would be a good idea 
too.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=801413315-24082007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=801413315-24082007><FONT face=Arial 
color=#0000ff size=2>Perhaps the default ASM wrapper around the RHS could use a 
try...catch block and log any exceptions of a rules' activation in a (drools) 
accessible log? Heck you could even allow certain accepted exceptions to be 
defined as a property of the rule; and any other non-defined exception types 
cause the session to become invalidated. If we're ever to let "the business" 
define rules we need to accept they might make mistakes that we're better off 
capturing and report back than invalidate the whole session. </FONT></SPAN><SPAN 
class=801413315-24082007><FONT face=Arial color=#0000ff size=2>Why should a 
whole session be invalidated because a single rule activation failed 
anyway?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=801413315-24082007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=801413315-24082007><FONT face=Arial 
color=#0000ff size=2>With kind regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=801413315-24082007></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=801413315-24082007><FONT face=Arial 
color=#0000ff size=2>Mike</FONT>&nbsp;</SPAN></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
  [mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Yang 
  Song<BR><B>Sent:</B> 24 August 2007 16:16<BR><B>To:</B> Rules Users 
  List<BR><B>Subject:</B> Re: [rules-users] How to catch Exceptions when firing 
  rules<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV>Thanks a lot for the answer, Mark. But I don't think it makes sense. 
  </DIV>
  <DIV>&nbsp;</DIV>
  <DIV>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. </DIV>
  <DIV>&nbsp;</DIV>
  <DIV>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&nbsp;can&nbsp;do something, e.g. create a new session. Also it should 
  enable the&nbsp;rule firer&nbsp;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. </DIV>
  <DIV>&nbsp;</DIV>
  <DIV>What do you think? If JBoss Rules already has the ability to do this job, 
  can you please let me know?</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Thanks again,</DIV>
  <DIV>Yang<BR><BR>&nbsp;</DIV>
  <DIV><SPAN class=gmail_quote>On 8/24/07, <B class=gmail_sendername>Mark 
  Proctor</B> &lt;<A 
  href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</A>&gt; 
  wrote:</SPAN> 
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
    <DIV bgcolor="#ffffff" text="#000000">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.<BR><BR>Mark<BR>Yang Song 
    wrote: 
    <BLOCKQUOTE type="cite">
      <DIV><SPAN class=e id=q_114978d8fa9e2dee_1>
      <DIV>Hi, </DIV>
      <DIV>&nbsp;</DIV>
      <DIV>Anyone knows how to catch the exception when firing the rules? </DIV>
      <DIV>&nbsp;</DIV>
      <DIV>I wrapped the session.fireAllRules() method using try...catch, 
      however it doesn't work: when someone wrote&nbsp;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 --&nbsp;the try...catch 
      outside doesn't help anything. </DIV>
      <DIV>&nbsp;</DIV>
      <DIV>If&nbsp;&nbsp;the exception&nbsp;thrown from&nbsp;the rule's action 
      part&nbsp;can be caught externally,&nbsp;the system can be protected from 
      interrupting Exception.</DIV>
      <DIV>
      <P><FONT style="BACKGROUND-COLOR: rgb(255,255,255)" 
      face="courier new,monospace" color=#3333ff>try 
      {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.debug("Firing rules 
      in : " + getName());</FONT></P>
      <P><FONT style="BACKGROUND-COLOR: rgb(255,255,255)" 
      face="courier new,monospace" 
      color=#3333ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      session.fireAllRules();</FONT></P>
      <P><FONT style="BACKGROUND-COLOR: rgb(255,255,255)" 
      face="courier new,monospace" color=#3333ff>} catch (Exception e) 
      {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.info("Error when 
      firing rules: ", e);<BR>}</FONT> <BR></P>
      <P>Thanks, <BR>Yang</P></DIV></SPAN></DIV><PRE><HR width="90%" SIZE=4>
_______________________________________________
rules-users mailing list
<A onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org" target=_blank>rules-users@lists.jboss.org</A>
<A onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A>
  </PRE></BLOCKQUOTE><BR>&nbsp;</DIV><BR>_______________________________________________<BR>rules-users 
    mailing list<BR><A onclick="return top.js.OpenExtLink(window,event,this)" 
    href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org 
    </A><BR><A onclick="return top.js.OpenExtLink(window,event,this)" 
    href="https://lists.jboss.org/mailman/listinfo/rules-users" 
    target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>