martiniman
(martiniman)
January 3, 2018, 11:40am
1
Why catch error do not work in my case? GasCounter_PrevDay
has state 2.26
I got error and rule stop processing:
2018-01-03 14:38:40.169 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'OLED Resresh NEW': Could not cast NULL to java.lang.Number; line 181, column 68, length 34
try {
...
var t = GasCounter_PrevDay.state as Number
...
} catch ( Throwable e) {
logWarn (" ---> Devices", "Oled page3 error " + e)
OledLines.set(23," Loading... " )
}
hr3
(Harry)
January 3, 2018, 1:32pm
2
catch(Exception e) and catch(Throwable e) seems to don’t work. Try
if (GasCounter_PrevDay.state != NULL) {...
I found that if i exit rule with return ;
, and return ;
was in try catch
- other try catch
stops working.
rlkoshak
(Rich Koshak)
January 4, 2018, 10:38pm
4
It doesn’t work because that is a language error that is not thrown as an exception. Like Harry, said, you need to check for NULL before you try casting it to Number.