/
Mikhail823
/
todo
Обзор
Документация
Войти
/
Mikhail823
/
todo
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/adjust-sourcemap-loader/lib/process/throw-errors.js
30 строк
841 B
Mikhail Popov
j
23 фев 2026, 16:12
23 фев 2026, 16:12
ff7232a
Код
Авторство
О чём код?
'use strict'; var getError = require('./get-error'); /** * Where the given list is non-null and contains error instances then consolidate and throw * @throws Error * @param {string} resourcePath The path to the resource being processed * @param {null|Array} candidates A possible Array with possible error elements */ function throwErrors(resourcePath, candidates) { var errors = !!candidates && candidates .filter(testIsError) .map(getMessage); var hasError = !!errors && errors.length; if (hasError) { throw getError(['For resource: ' + resourcePath].concat(errors).join('\n')); } function testIsError(candidate) { return !!candidate && (typeof candidate === 'object') && (candidate instanceof Error); } function getMessage(error) { return error.message; } } module.exports = throwErrors;