Skip to content

Commit 00b2e0a

Browse files
committed
Use or_raise to handle build errors
1 parent 6dea2bd commit 00b2e0a

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/dodal/device_manager.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,13 @@ def build(
163163
self,
164164
fixtures=fixtures,
165165
mock=mock,
166-
)
167-
if devices.errors:
168-
# TODO: NotBuilt?
169-
raise Exception("??? build")
170-
else:
171-
if connect_immediately:
172-
conn = devices.connect(timeout=timeout or self.timeout)
173-
if conn.connection_errors:
174-
# TODO: NotConnected?
175-
raise Exception("??? conn")
176-
device = devices.devices[self.name].device
177-
if name:
178-
device.set_name(name)
179-
return device # type: ignore - it's us, honest
166+
).or_raise()
167+
if connect_immediately:
168+
devices.connect(timeout=timeout or self.timeout).or_raise()
169+
device = devices.devices[self.name].device
170+
if name:
171+
device.set_name(name)
172+
return device # type: ignore - it's us, honest
180173

181174
def _create(self, *args, **kwargs) -> V2:
182175
return self(*args, **kwargs)

0 commit comments

Comments
 (0)