Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 5, 2022
1 parent 347a9c3 commit 84d85cb
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/error/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,11 @@ const mergeAggregate = function (mergedError, parentErrors, child) {
}

const getAggregateErrors = function (error) {
const { errors } = error
return hasAggregateErrors(error, errors)
? errors.map(mergeErrorCause)
return Array.isArray(error.errors)
? error.errors.map(mergeErrorCause)
: undefined
}

const hasAggregateErrors = function (error, errors) {
return (
errors !== undefined &&
Array.isArray(errors) &&
(error instanceof AggregateError || errors.some(isErrorInstance))
)
}

const isErrorInstance = function (error) {
return error instanceof Error
}

const getMergedErrors = function (parentErrors, childErrors) {
if (parentErrors === undefined) {
return childErrors
Expand Down

0 comments on commit 84d85cb

Please sign in to comment.