Commit d2df3df6 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[widgets][editor] Show error message on new asset creation failure

For example, if a default Algorithm can't be constructed because the
prefix used lacks the reference datformats, show the exception message
rather than make the application crash.
parent 0c48f1f3
......@@ -116,13 +116,19 @@ class AbstractAssetEditor(QWidget):
if ok_pressed:
user = self.context.meta["config"].user
error_message = None
status = False
if creation_type == AssetCreationDialog.NEW:
if self.asset_type.split_count() == 1:
asset_name = f"{asset_info}/1"
else:
asset_name = f"{user}/{asset_info}/1"
status = self.asset_type.create_new(self.prefix_path, asset_name)
try:
status = self.asset_type.create_new(self.prefix_path, asset_name)
except RuntimeError as error:
error_message = str(error)
elif creation_type == AssetCreationDialog.NEW_VERSION:
status = self.asset_type.create_new_version(
self.prefix_path, asset_info
......@@ -145,16 +151,17 @@ class AbstractAssetEditor(QWidget):
)
if not status:
QMessageBox.critical(
self,
self.tr("Error occurred"),
self.tr(
"The {} operation failed".format(
AssetCreationDialog.typeToString(creation_type)
)
),
error_text = self.tr(
"The {} operation failed".format(
AssetCreationDialog.typeToString(creation_type)
)
)
if error_message:
error_text += self.tr("\nReason:{}".format(error_message))
QMessageBox.critical(self, self.tr("Error occurred"), error_text)
def _load_json(self, json_object):
"""To be implemented by subclass to load their specific JSON parts"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment