More precise schema failure message

While creating schema for the add-on I used, I realized that my error
message was not precise enough.

For a big configuration such as in "Enhance main window", the message
"None is not of type 'string'" is almost useless.
So I added a path in the json config, to indicate where the error
is. And also which subschema is currently being used.
This commit is contained in:
Arthur Milchior 2020-03-08 16:27:53 +01:00
parent 4290bc81eb
commit c9b89c5394
2 changed files with 9 additions and 2 deletions

View File

@ -1330,7 +1330,14 @@ class ConfigEditor(QDialog):
except ValidationError as e:
# The user did edit the configuration and entered a value
# which can not be interpreted.
showInfo(tr(TR.ADDONS_CONFIG_VALIDATION_ERROR, problem=e.message))
showInfo(
tr(
TR.ADDONS_CONFIG_VALIDATION_ERROR,
problem=e.message,
path="/".join(str(path) for path in e.path),
schema=str(e.schema),
)
)
return
except Exception as e:
showInfo(_("Invalid configuration: ") + repr(e))

View File

@ -6,4 +6,4 @@ addons-failed-to-load =
{$traceback}
# Shown in the add-on configuration screen (Tools>Add-ons>Config), in the title bar
addons-config-window-title = Configure '{$name}'
addons-config-validation-error = There was a problem with the provided configuration: {$problem}
addons-config-validation-error = There was a problem with the provided configuration: {$problem}, at path {$path}, against schema {$schema}.