From d267a752cd0f5483e9e6db3d387feb0948cb720d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 16 Feb 2016 09:13:22 +0100 Subject: [PATCH] Capture NoSuchStorage error on SD card fails We currently do not have a storage configured for SD card since that hasn't yet been ported to the storage interface. So on an SD card fail we need to capture that error when attempting to log the print recovery data, or there will be issues processing the cancel properly. A bit more of error handling is a good idea here in any case too. Fixes #1226 --- src/octoprint/printer/standard.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 1d50e519..ec847278 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -17,7 +17,7 @@ import time from octoprint import util as util from octoprint.events import eventManager, Events -from octoprint.filemanager import FileDestinations +from octoprint.filemanager import FileDestinations, NoSuchStorage from octoprint.plugin import plugin_manager, ProgressPlugin from octoprint.printer import PrinterInterface, PrinterCallback, UnknownScript from octoprint.printer.estimation import TimeEstimationHelper @@ -865,7 +865,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self.disconnect() def on_comm_record_fileposition(self, origin, name, pos): - self._fileManager.save_recovery_data(origin, name, pos) + try: + self._fileManager.save_recovery_data(origin, name, pos) + except NoSuchStorage: + pass + except: + self._logger.exception("Error while trying to persist print recovery data") class StateMonitor(object): def __init__(self, interval=0.5, on_update=None, on_add_temperature=None, on_add_log=None, on_add_message=None):