mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Catch correct exceptions
To catch the exception of duplicate file types, catch only the exception that triggers at this, OPCError. To catch generic file writing errors, catch all of EnvironmentError, not just OSError.
This commit is contained in:
parent
66f57d4d58
commit
9a65008952
1 changed files with 3 additions and 2 deletions
|
@ -5,6 +5,7 @@ from typing import cast, List, Dict
|
|||
|
||||
from Charon.VirtualFile import VirtualFile # To open UFP files.
|
||||
from Charon.OpenMode import OpenMode # To indicate that we want to write to UFP files.
|
||||
from Charon.filetypes.OpenPackagingConvention import OPCError
|
||||
from io import StringIO # For converting g-code to bytes.
|
||||
|
||||
from PyQt5.QtCore import QBuffer
|
||||
|
@ -90,7 +91,7 @@ class UFPWriter(MeshWriter):
|
|||
|
||||
try:
|
||||
archive.addContentType(extension = material_extension, mime_type = material_mime_type)
|
||||
except:
|
||||
except OPCError:
|
||||
Logger.log("w", "The material extension: %s was already added", material_extension)
|
||||
|
||||
added_materials = []
|
||||
|
@ -130,7 +131,7 @@ class UFPWriter(MeshWriter):
|
|||
|
||||
try:
|
||||
archive.close()
|
||||
except OSError as e:
|
||||
except EnvironmentError as e:
|
||||
error_msg = catalog.i18nc("@info:error", "Can't write to UFP file:") + " " + str(e)
|
||||
self.setInformation(error_msg)
|
||||
Logger.error(error_msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue