gcode: Simplify exception handling

Translate caught exceptions into a gcode.error() exception.  This way
there is one standard place to invoke respond_error().  Also, always
reset the last_position on a handled error.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-12-03 19:30:49 -05:00
parent 3a2d16abb3
commit 80f23441dd
2 changed files with 21 additions and 20 deletions

View file

@ -328,7 +328,11 @@ class ToolHead:
if self.print_time > self.need_check_stall:
self._check_stall()
def home(self, homing_state):
self.kin.home(homing_state)
try:
self.kin.home(homing_state)
except homing.EndstopError as e:
self.motor_off()
raise
def dwell(self, delay, check_stall=True):
self.get_last_move_time()
self.update_move_time(delay)