Rule try/catch no longer quashes exception

I have the following items


Group g_test1

Number hhtest1 (g_test1)
Number hhtest2 (g_test1)
Number hhtest3 (g_test1)

and rule

rule "DDD"
when Member of g_test1 changed
then
    var partnerLightsItem = null 
    logWarn("loggerName", "1")
    try { 
        logWarn("loggerName", "2")
        partnerLightsItem = ScriptServiceUtil.getItemRegistry.getItem("NonsenseItem")
        logWarn("loggerName", "3")
    } 
    catch(Excpetion ex)
    {
        logWarn("loggerName", "4")
    }
    logWarn("loggerName", "5")

end

If the item was not found in the registry in 2.5 the try/catch caught and quashed the exception.
In 3.0 it does not and the rule stops running

You can see above that debug 3 and 4 do not show.
All my rules check to see if the optional item exists, if not, they exit cleanly (return; in the exception) but now that does not happen and the log fills with errors.

I’ll log this as a bug too

Is this what’s in your rule? Because it contains a typo.

Doh. It certainly is a spelling mistake.
It’s still the same though - does not catch the exception. Unless I am going mad. :smiley:

Off-topic - Not a fix, but there are alternative methods to search for an Item within a Group by name string. If not exist, it returns an easy to handle null instead of throwing an exception.

yup, I have those too. I switched this this so I don’t have to do a “pointless” group. I’ll switch these back in the meantime.

Just wondering if this is another nuance for me or a wider problem?

I had to way zoom in on my phone (please don’t post screenshots of text, you clearly already know how to use code fences, use them for logs as well). The error isn’t that the Item doesn’t exist, the problem reported is ScriptServiceUtil doesn’t exist. Did you import it? You don’t get it by default without importing it.

1 Like

Cannot believe I did not import them. Clearly need more sleep / coffee / wine / all of them. :slight_smile:

Yup, that’s the issue. Thanks for pointing out the obvious :slight_smile: