Class Cast Exception help

The log shows this runtime error:
java.lang.ClassCastException: null (sleepScoreHandler)

No line number. I have looked in the method sleepScoreHandler, but can't identify any "casting" that could throw an exception because of a null value.

My approach to debugging this is to insert a bunch of log.debug statements into the code to see what the value of variables is at various places. Is there some other, more efficient approach to this though? I don't understand why HE fails to give me a line number for debugging?

Note: my question here is more about what approach to take to debug this, rather than what's specifically wrong with my code.

Seems more likely to mean that "sleepScoreHandler" itself is returning null and you're trying to use the return value somewhere that tries to cast it to type that it can't be cast to.

Afraid you'll probably have to post the code else it's difficult to offer any ideas.

In general debugging in HE is mostly using log.debug calls i.e.

log.debug(" here I am: ${what_is_this_variable_now}")

.... lots of code

log.debug(" now I'm here: ${what_is_this_variable_now}")
log.debug(" does my method actually return something? ${sleepScoreHandler()}")

Download the Hubitat app