From c9b89c53940f4fb06753b54743904fcbf613522f Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Sun, 8 Mar 2020 16:27:53 +0100 Subject: [PATCH] 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. --- qt/aqt/addons.py | 9 ++++++++- qt/ftl/addons.ftl | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index 0b1e04ac6..58be30716 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -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)) diff --git a/qt/ftl/addons.ftl b/qt/ftl/addons.ftl index 4ba2ddb93..6cfa040b9 100644 --- a/qt/ftl/addons.ftl +++ b/qt/ftl/addons.ftl @@ -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} \ No newline at end of file +addons-config-validation-error = There was a problem with the provided configuration: {$problem}, at path {$path}, against schema {$schema}. \ No newline at end of file