From 6a3f1d28fb2381c5f6264bdfa6099211c2a68d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 6 Mar 2018 15:08:41 +0100 Subject: [PATCH] Reduce code duplication in error handling --- src/octoprint/util/comm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index f47721679..765571573 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2258,18 +2258,18 @@ class MachineCom(object): if ret: return line - error_text = line[6:] if lower_line.startswith("error:") else line[2:] - self._to_logfile_with_terminal(u"Received an error from the printer's firmware: {}".format(error_text), + self._to_logfile_with_terminal(u"Received an error from the printer's firmware: {}".format(stripped_error), level=logging.WARN) if not self._ignore_errors: if self._disconnect_on_errors: - self._trigger_error(error_text, "firmware") + self._trigger_error(stripped_error, "firmware") elif self.isPrinting(): - self.cancelPrint(firmware_error=error_text) + self.cancelPrint(firmware_error=stripped_error) self._clear_to_send.set() else: - self._log("WARNING! Received an error from the printer's firmware, ignoring that as configured but you might want to investigate what happened here! Error: {}".format(error_text)) + self._log("WARNING! Received an error from the printer's firmware, ignoring that as configured " + "but you might want to investigate what happened here! Error: {}".format(stripped_error)) self._clear_to_send.set() # finally return the line