raise...from info missing in DevFailed
Closed this issue · 0 comments
reszelaz commented
I would like that the exception chain is propagated to the client.
I have the following device server:
from tango.server import Device, attribute
class DeviceRaiseFrom(Device):
attr1 = attribute()
def read_attr1(self):
try:
raise Exception("err1")
except Exception as e:
raise Exception("err2") from e
if __name__ == "__main__":
DeviceRaiseFrom.run_server()
I run it in the following way:
tango_admin --add-server DeviceRaiseFrom/test DeviceRaiseFrom test/deviceraisefrom/1
python3 DeviceRaiseFrom.py test -v4
In itango3 I get:
In [1]: d = DeviceRaiseFrom('test/deviceraisefrom/1')
In [2]: d.attr1
PyDs_PythonError: Exception: err2
(For more detailed information type: tango_error)
In [3]: tango_error
Last tango error:
DevFailed[
DevError[
desc = Exception: err2
origin = File "/home/zreszela/workspace/pytango/tango/server.py", line 132, in read_attr
ret = worker.execute(read_method, self)
File "/home/zreszela/workspace/pytango/tango/green.py", line 98, in execute
return fn(*args, **kwargs)
File "DeviceRaiseFrom.py", line 13, in read_attr1
raise Exception("err2") from e
reason = PyDs_PythonError
severity = ERR]
DevError[
desc = Failed to read_attribute on device test/deviceraisefrom/1, attribute attr1
origin = DeviceProxy::read_attribute()
reason = API_AttributeFailed
severity = ERR]
]
In [4]: try:
...: raise Exception("err1")
...: except Exception as e:
...: raise Exception("err2") from e
...:
Exception: err2
(For more detailed information type: python_error)
In [5]:
In [5]: python_error
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-4-055cdc174ea6> in <module>()
1 try:
----> 2 raise Exception("err1")
3 except Exception as e:
Exception: err1
The above exception was the direct cause of the following exception:
Exception Traceback (most recent call last)
<ipython-input-4-055cdc174ea6> in <module>()
2 raise Exception("err1")
3 except Exception as e:
----> 4 raise Exception("err2") from e
Exception: err2
As you can see in PyTango the info about the original exception is lost.