I have a function: MQTTReceiveMsg. It si called ONMQTT. Eg:
ONMQTT “@MQTTReceiveMsg()”
I tracked a bug to this function, but in order to figure out which line specifically is throwing the error, I added a linenumber variable between each line like thus:
LineNumber$=“1”
$ReadMessageLoop:
LineNumber$=“2”
MessageQty%=Mqtt “READ” //Return the number of pending messages
LineNumber$=“3”
IF (MessageQty%>0) Then
…
LineNumber$=“NaN”
ENDFN
My error handler then logs this when an error occurs:
ERROR:
LOGEVENT "Error in " + FunctionName$ + " on line " + LineNumber$,120
However, my log file is full of this:
Error in MQTTReceiveMsg on line NaN
Are errors only thrown at the end of the function? It seems crazy to me that if there is an error in a function it would continue to run the function and update variables even though an errored state exists.