To raise a Tango exception say:
if not doorname: PyTango.Except.throw_exception( "n.n.", "no doorname supplied", "vc_pilatus.__init__")
To re-throw an exception use:
try: door = PyTango.DeviceProxy( doorname) except PyTango.DevFailed as e: PyTango.Except.re_throw_exception( e, "from DeviceProxy", "failed to create proxy to door %s " % doorname, "Hasylab.getSardanaProxies")
This is how an exception is caught:
#!/usr/bin/env python import PyTango try: dev = PyTango.DeviceProxy( "abc") except PyTango.DevFailed as e: PyTango.Except.print_exception( e)
To customize the ouput:
try: val = proxy.read_attribute( attr).value except PyTango.DevFailed as e: print( " %-15s: error" % (attr)) for arg in e.args: print( " Desc: %s" % (arg.desc)) #print( "origin: %s" % (arg.origin)) #print( "reason: %s" % (arg.reason)) #print( "severity: %s" % (arg.severity))