[rules-users] Exception Handling in the rule

Swindells, Thomas TSwindells at nds.com
Tue Jun 7 04:36:08 EDT 2011


Firstly evals have to evaluate true or false - what you have here appears to return a string -
presumably you are actually comparing this to some value?

One, not particularly elegant or efficient method is to do the check within your eval, eg:

eval(ClaimsHistoryHelper.getClaimDrug(drugRefNo) == null ? false : drugName == (ClaimsHistoryHelper.getClaimDrug(drugRefNo)).getDrugName())

If your ClaimsHistoryHelper is doing a time consuming operation (eg going to a db  etc), you can probably make a very quick and simple efficiency saving by having it cache the last result it searched for/returned (or depending on how many drugRefNo you are looking up a more complete caching solution).

Thomas
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org [mailto:rules-users-
> bounces at lists.jboss.org] On Behalf Of sdinoo
> Sent: 07 June 2011 06:22
> To: rules-users at lists.jboss.org
> Subject: [rules-users] Exception Handling in the rule
>
> Hi,
>
> In my when clause I have an eval statement like this
>
> eval((ClaimsHistoryHelper.getClaimDrug(drugRefNo)).getDrugName())
>
> For some reason, there is no DrugRecord for the given drugRefNo and hence
> I get javaNullPointer exceptions I do want to rule to continue evaluation and
> not stop with the error and hence I dont want to handle exception at
> fireAllRules catch block
>
> How can I handle the exception in the DRL ?
>
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Exception-
> Handling-in-the-rule-tp3033223p3033223.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************




More information about the rules-users mailing list