mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix init error message(s) formatting
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user