Page 1 of 1

Error Python : Return name Error

Posted: Wednesday 29 March 2017 11:18
by St7ven
Hi,

I get this error : Error: (Controler) 'onMessage' failed 'NameError'. But I can retrieve the name that make this error.

In a python, the name usually follow the error. How could I bring up the faulty name ?

Re: Error Python : Return name Error

Posted: Wednesday 29 March 2017 12:45
by Dnpwwo
@St7ven,

The Python framework will return all the information it can but sometimes Python does not make a traceback or the details available.

I would suggest added an error handler something like this around your onMessage function:

Code: Select all

    def onMessage(self, Data, Status, Extra):
        strData = Data.decode("utf-8", "ignore")
        try:
        
...your code here...

        except Exception as inst:
            Domoticz.Error("Exception in onMessage, called with Data: '"+str(strData)+"'")
            Domoticz.Error("Exception detail: '"+str(inst)+"'")
            raise
a construct like that has given me more detail and may help you out.

The 'raise' at the end will pass the error back to Domoticz.

Re: Error Python : Return name Error

Posted: Wednesday 29 March 2017 17:40
by St7ven
Thank you Dnpwwo,

It helps a lot !