From 80f23441dddf4f728f840d7f3b2bc4ddb42f3219 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 3 Dec 2017 19:30:49 -0500 Subject: 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 --- klippy/toolhead.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'klippy/toolhead.py') diff --git a/klippy/toolhead.py b/klippy/toolhead.py index dde40e9b..3a73bb26 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -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) -- cgit v1.2.3-70-g09d2