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

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