Improve exception info when command execution failed
Closes #603 (closed)
It is an interesting case. It is supposed, that we should handle such errors. But in case of command, when we try to convert output data to tango type and get python's TypeError, error convert to DevFaild fails here. The reason is, that there cannot be any python's traceback at this point, as execution of python's code already done, and we on the way back to the c++:
c++ core
-> bindings
-> python's code
<- back to bindings: here we fails, but python's traceback here is zero!
To handle such case, I propose, that in such cases as the origin we print something like "UNKNOWN: cannot get Python's traceback. Most probably, was a failure in c++ bindings". I also added optional parameters in handle_python_exception
, so we can add additional layer in DevFailed, and propose, that in case of command failure we add this info:
DevError[
desc = Cannot execute command
origin = virtual CORBA::Any* PyCmd::execute(Tango::DeviceImpl*, const CORBA::Any&) at (/home/matveyev/pytango/ext/server/command.cpp:325)
reason = PyDs_UnexpectedFailure
severity = ERR]
So, now the error, when we cannot conver out parameters look like:
PyTango.DevFailed: DevFailed[
DevError[
desc = TypeError: Expecting a integer type but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)
origin = UNKNOWN: cannot get Python's traceback. Most probably, was a failure in c++ bindings
reason = PyDs_PythonError
severity = ERR]
DevError[
desc = Cannot execute command
origin = virtual CORBA::Any* PyCmd::execute(Tango::DeviceImpl*, const CORBA::Any&) at (/home/matveyev/pytango/ext/server/command.cpp:325)
reason = PyDs_UnexpectedFailure
severity = ERR]
DevError[
desc = Failed to execute command_inout on device test/nodb/mydevice, command mycommand
origin = virtual Tango::DeviceData Tango::Connection::command_inout(const std::string&, const Tango::DeviceData&) at (/home/matveyev/cppTango/src/client/devapi_base.cpp:1418)
reason = API_CommandFailed
severity = ERR]