Browse Source

Catch OSError and related errors when saving workspaces

This should prevent a crash when saving to a path that the file system doesn't support (because of e.g. disallowed symbols in the file name).

Instead it will now show an error message to the user.

Fixes Sentry issue CURA-157.
Ghostkeeper 4 years ago
parent
commit
1ce8ef3293
1 changed files with 4 additions and 0 deletions
  1. 4 0
      plugins/3MFWriter/ThreeMFWorkspaceWriter.py

+ 4 - 0
plugins/3MFWriter/ThreeMFWorkspaceWriter.py

@@ -92,6 +92,10 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
             self.setInformation(catalog.i18nc("@error:zip", "No permission to write the workspace here."))
             Logger.error("No permission to write workspace to this stream.")
             return False
+        except EnvironmentError as e:
+            self.setInformation(catalog.i18nc("@error:zip", "The operating system does not allow saving a project file to this location or with this file name."))
+            Logger.error("EnvironmentError when writing workspace to this stream: {err}".format(err = str(e)))
+            return False
         mesh_writer.setStoreArchive(False)
         return True