Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 5, 2022
1 parent ece662e commit 8cae6f2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/error/modern/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import normalizeException from 'normalize-exception'
// Otherwise, assign a default SystemError type.
export const allowErrorTypes = function (error, ErrorTypes, SystemError) {
const errorA = normalizeException(error)
return ErrorTypes.some((ErrorType) => errorA instanceof ErrorType)
? errorA
: mergeErrorCause(new SystemError('', { cause: errorA }))

if (ErrorTypes.some((ErrorType) => errorA instanceof ErrorType)) {
return errorA
}

const systemError = new SystemError('', { cause: errorA })
return mergeErrorCause(systemError)
}

0 comments on commit 8cae6f2

Please sign in to comment.