Skip to content
Snippets Groups Projects

Grx displays error message instead of crashing

1 file
+ 15
0
Compare changes
  • Side-by-side
  • Inline
@@ -183,12 +183,27 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem):
"""
try:
parsed_value = ast.literal_eval(value)
# ast.literal_eval only raises an error the the
# parsed value isn't a valid data type.
# If the user edits GRX and enters a string "a"
# it will crash
if isinstance(parsed_value, list):
for value in parsed_value:
if isinstance(value, str):
raise TypeError
except SyntaxError as e:
self.errorMessageWidget.showMessage(str(e))
except ValueError as e:
self.errorMessageWidget.showMessage(
"Value Error. Unable to parse input. Make sure it is in the correct base."
)
except TypeError as e:
self.errorMessageWidget.showMessage(
"Type Error. Unable to parse input. Make sure it is the correct type."
)
else:
module_state = self.module.get_state()
module_state[state] = parsed_value
Loading