<br>&nbsp;&nbsp; Mark,<br><br>&nbsp;&nbsp; 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.
<br>&nbsp;&nbsp; I also think this would be good when we move to areas like high-availability as we were discussing the other day.<br>&nbsp;&nbsp; I would say, lets investigate and maybe add some support for next feature release (4.2 or whatever).
<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/8/24, Mark Proctor &lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



  

<div bgcolor="#ffffff" text="#000000">
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.<br>
<br>
Beyond the above, I guess I don&#39;t understand what it is you are looking
for.<br><span class="sg">
<br>
Mark</span><div><span class="e" id="q_11498a57d0f3c1e5_2"><br>
Yang Song wrote:
<blockquote type="cite">
  <div>Thanks a lot for the answer, Mark. But I don&#39;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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mproctor@codehaus.org
</a>&gt;
wrote:</span>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
    <div text="#000000" bgcolor="#ffffff">Once an exception is thrown
on a conseuqence the current session is considered invalid. You&#39;ll need
to add the try catch inside of the actual consequence.<br>
    <br>
Mark<br>
Yang Song wrote:
    <blockquote type="cite">
      <div><span>
      <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&#39;t work: when someone wrote&nbsp;bad code in
the rule&#39;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&#39;t help anything. </div>
      <div>&nbsp;</div>
      <div>If&nbsp;&nbsp;the exception&nbsp;thrown from&nbsp;the rule&#39;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);" color="#3333ff" face="courier new,monospace">try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.debug(&quot;Firing rules in : &quot; + getName());</font></p>
      <p><font style="background-color: rgb(255, 255, 255);" color="#3333ff" face="courier new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
session.fireAllRules();</font></p>
      <p><font style="background-color: rgb(255, 255, 255);" color="#3333ff" face="courier new,monospace">} catch (Exception e) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.info(&quot;Error when firing rules: &quot;, e);<br>
}</font> <br>
      </p>
      <p>Thanks, <br>
Yang</p>
      </div>
      </span></div>
      <pre><hr size="4" width="90%">
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org
</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
    </blockquote>
    <br>
&nbsp;</div>
    <br>
_______________________________________________<br>
rules-users mailing list<br>
    <a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org
    </a><br>
    <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
    <br>
  </blockquote>
  </div>
  <br>
  <pre><hr size="4" width="90%">
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org
</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</span></div></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><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>