UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

33 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.errorAnalyzer = void 0; const constants_1 = require("../../constants"); const dictionary_1 = require("../dictionary"); const snowflake_1 = require("./snowflake"); const elasticsearch_1 = require("./elasticsearch"); const redshift_1 = require("./redshift"); const postgresql_1 = require("./postgresql"); function errorAnalyzer(engine, errorObj) { const info = { [constants_1.ENGINES.ELASTICSEARCH]: elasticsearch_1.getInfo, [constants_1.ENGINES.SNOWFLAKE]: snowflake_1.getInfo, [constants_1.ENGINES.REDSHIFT]: redshift_1.getInfo, [constants_1.ENGINES.POSTGRESQL]: postgresql_1.getInfo, }; const { errorList, messageList } = info[engine](errorObj); const currentError = analyzer(messageList, errorList); return Object.assign({ valid: false, source: constants_1.RESPONSE_LEVEL.runtime, info: errorObj }, currentError); } exports.errorAnalyzer = errorAnalyzer; function analyzer(messageList, errorList) { let result = dictionary_1.ERROR_DICTIONARY.unknown; messageList.forEach((message) => { errorList.forEach((element) => { const regex = new RegExp(element.regex, 'g'); if (regex.test(message)) result = dictionary_1.ERROR_DICTIONARY[element.value]; }); }); return result; } //# sourceMappingURL=index.js.map