From 32be5ca87c6dddf49bd701d2be109f7f6f00d8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 24 Sep 2018 16:50:14 +0200 Subject: [PATCH] Better error handling if file becomes unreadable Implements #2674 --- src/octoprint/util/comm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index dd784dd98..f8fa1c02f 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2601,7 +2601,14 @@ class MachineCom(object): if self._currentFile is None: return None, None, None - line, pos, lineno = self._currentFile.getNext() + try: + line, pos, lineno = self._currentFile.getNext() + except EnvironmentError: + self._log("There was an error reading from the file that's being printed, cancelling the print. Please " + "consult octoprint.log for details on the error.") + self.cancelPrint() + return None, None, None + if line is None: if isinstance(self._currentFile, StreamingGcodeFileInformation): self._finishFileTransfer()