<div>Thanks a lot for the answer, Mark. But I don't think it makes sense. </div>
<div> </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> </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 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.
</div>
<div> </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> </div>
<div>Thanks again,</div>
<div>Yang<br><br> </div>
<div><span class="gmail_quote">On 8/24/07, <b class="gmail_sendername">Mark Proctor</b> <<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div text="#000000" bgcolor="#ffffff">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> </div>
<div>Anyone knows how to catch the exception when firing the rules? </div>
<div> </div>
<div>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.
</div>
<div> </div>
<div>If the exception thrown from the rule's action part can be caught externally, 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> _log.debug("Firing rules in : " + getName());</font></p>
<p><font style="BACKGROUND-COLOR: rgb(255,255,255)" face="courier new,monospace" color="#3333ff"> session.fireAllRules();</font></p>
<p><font style="BACKGROUND-COLOR: rgb(255,255,255)" face="courier new,monospace" color="#3333ff">} catch (Exception e) {<br> _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> </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>