From b74aa1235154e32bb608e1c7ee0c9e2942d234ce Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 16 Apr 2016 19:55:08 +0800 Subject: [PATCH] master/worker_db: rethrow DeviceError exception with device name on device creation failure. Closes #396 --- artiq/master/worker_db.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index bd34ef143..0226e995e 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -112,6 +112,10 @@ def _create_device(desc, device_mgr): raise ValueError("Unsupported type in device DB: " + ty) +class DeviceError(Exception): + pass + + class DeviceManager: """Handles creation and destruction of local device drivers and controller RPC clients.""" @@ -141,7 +145,16 @@ class DeviceManager: if name in self.active_devices: return self.active_devices[name] else: - dev = _create_device(self.get_desc(name), self) + try: + desc = self.get_desc(name) + except Exception as e: + raise DeviceError("Failed to get description of device '{}'" + .format(name)) from e + try: + dev = _create_device(desc, self) + except Exception as e: + raise DeviceError("Failed to create device '{}'" + .format(name)) from e self.active_devices[name] = dev return dev