Skip to content

Commit db2e183

Browse files
authored
robot.run and robot.simulate re-raise exceptions instead of adding ro… (#159)
* robot.run and robot.simulate re-raise exceptions instead of adding robot warnings list * tests exceptions during robot run
1 parent f17d0ec commit db2e183

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

opentrons/robot/robot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,9 @@ def run(self, **kwargs):
766766
'name': 'command-failed',
767767
'error': str(e)
768768
})
769-
self.add_warning(str(e))
770-
break
769+
raise RuntimeError(
770+
'Command #{0} failed (\"{1}\"").\nError: \"{2}\"'.format(
771+
i, command.description, str(e))) from e
771772

772773
return self._runtime_warnings
773774

tests/opentrons/protocol/test_robot.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_stop_run(self):
6262

6363
def _run():
6464
nonlocal res
65-
res = self.robot.run()
65+
self.assertRaises(RuntimeError(self.robot.run))
6666

6767
thread = threading.Thread(target=_run)
6868
thread.start()
@@ -71,8 +71,17 @@ def _run():
7171

7272
thread.join()
7373

74-
self.assertEquals(
75-
res[-1], 'Received a STOP signal and exited from movements')
74+
def test_exceptions_during_run(self):
75+
p200 = instruments.Pipette(axis='b', name='my-fancy-pancy-pipette')
76+
77+
def _do():
78+
return 'hello' / 3
79+
80+
p200.create_command(
81+
do=_do,
82+
enqueue=True)
83+
84+
self.assertRaises(RuntimeError, self.robot.run)
7685

7786
def test_calibrated_max_dimension(self):
7887

0 commit comments

Comments
 (0)