klippy: Fix error handling during connect phase

Make sure to exit the _connect() method if a connect event handler
raises an error.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-01-08 13:46:26 -05:00
parent bf647749dd
commit c0ea0312e5
1 changed files with 4 additions and 0 deletions

View File

@ -137,16 +137,20 @@ class Printer:
except (self.config_error, pins.error) as e:
logging.exception("Config error")
self._set_state("%s%s" % (str(e), message_restart))
return
except msgproto.error as e:
logging.exception("Protocol error")
self._set_state("%s%s" % (str(e), message_protocol_error))
return
except mcu.error as e:
logging.exception("MCU error during connect")
self._set_state("%s%s" % (str(e), message_mcu_connect_error))
return
except:
logging.exception("Unhandled exception during connect")
self._set_state("Internal error during connect.%s" % (
message_restart,))
return
try:
self._set_state(message_ready)
for cb in self.event_handlers.get("klippy:ready", []):