Add information about parser/index to error messages when parsing configuration file content.

This commit is contained in:
David Anson 2021-11-30 21:28:59 -08:00
parent 925f9cd168
commit 7330ea4946
3 changed files with 10 additions and 6 deletions

View file

@ -1717,13 +1717,14 @@ function parseConfiguration(name, content, parsers) {
var config = null;
var message = "";
var errors = [];
var index = 0;
// Try each parser
(parsers || [JSON.parse]).every(function (parser) {
try {
config = parser(content);
}
catch (error) {
errors.push(error.message);
errors.push("Parser " + index++ + ": " + error.message);
}
return !config;
});