feat: allow plugins to throw an iterable list of errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const {identity} = require('lodash');
|
||||
const {identity, isFunction} = require('lodash');
|
||||
const pReflect = require('p-reflect');
|
||||
const pReduce = require('p-reduce');
|
||||
const AggregateError = require('aggregate-error');
|
||||
@@ -15,7 +15,11 @@ module.exports = steps => async (input, settleAll = false, getNextInput = identi
|
||||
if (settleAll) {
|
||||
const {isFulfilled, value, reason} = await pReflect(nextStep(prevResult));
|
||||
result = isFulfilled ? value : reason;
|
||||
(isFulfilled ? results : errors).push(result);
|
||||
if (isFulfilled) {
|
||||
results.push(result);
|
||||
} else {
|
||||
errors.push(...(result && isFunction(result[Symbol.iterator]) ? result : [result]));
|
||||
}
|
||||
} else {
|
||||
result = await nextStep(prevResult);
|
||||
results.push(result);
|
||||
|
||||
Reference in New Issue
Block a user