diff --git a/src/gui/html/js/initialise.js b/src/gui/html/js/initialise.js
index 7762a202..e3fcebf8 100644
--- a/src/gui/html/js/initialise.js
+++ b/src/gui/html/js/initialise.js
@@ -131,18 +131,25 @@
function getInitErrors() {
return query('getInitErrors').then((result) => {
- if (JSON.parse(result)) {
+ const errors = JSON.parse(result);
+ if (errors.length > 0) {
throw new Error(result);
}
});
}
- function handleInitErrors(error) {
- if (error.constructor === Array) {
- dom.listInitErrors(JSON.parse(error.message));
- } else {
- dom.listInitErrors([error.message]);
+ function getErrorMessages(string) {
+ /* error.message could be a message string or JSON encoding a list of
+ message strings. */
+ try {
+ return JSON.parse(string);
+ } catch (error) {
+ return [string];
}
+ }
+
+ function handleInitErrors(error) {
+ dom.listInitErrors(getErrorMessages(error.message));
Dialog.closeProgress();
dom.openDialog('settingsDialog');
}
diff --git a/src/gui/query/get_init_errors_query.h b/src/gui/query/get_init_errors_query.h
index d2d36b75..1af76afd 100644
--- a/src/gui/query/get_init_errors_query.h
+++ b/src/gui/query/get_init_errors_query.h
@@ -35,11 +35,7 @@ public:
GetInitErrorsQuery(LootState& state) : state_(state) {}
std::string executeLogic() {
- YAML::Node node(state_.getInitErrors());
- if (node.size() > 0)
- return JSON::stringify(node);
-
- return "null";
+ return JSON::stringify(YAML::Node(state_.getInitErrors()));
}
private: