Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 5, 2022
1 parent 97848f4 commit 9ff31a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 88 deletions.
8 changes: 4 additions & 4 deletions src/error/types.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { mergeErrorCause } from './merge/main.js'
import { normalizeError } from './normalize/main.js'
import { wrapError } from './wrap.js'

// Ensure an error is among a specific set of error types.
// Otherwise, assign a default error type (`errorTypes[0]`).
export const allowErrorTypes = function (error, errorTypes) {
export const allowErrorTypes = function (error, ErrorTypes) {
const errorA = normalizeError(error)
return errorTypes.some((errorType) => errorA instanceof errorType)
return ErrorTypes.some((ErrorType) => errorA instanceof ErrorType)
? errorA
: wrapError(errorA, '', errorTypes[0])
: mergeErrorCause(new ErrorTypes[0]('', { cause: errorA }))
}
84 changes: 0 additions & 84 deletions src/error/wrap.js

This file was deleted.

0 comments on commit 9ff31a8

Please sign in to comment.