import { BaseError } from "make-error-cause" ; export function causeOf ( error ) { if ( error instanceof BaseError ) { return error . cause ; } return undefined ; } export function anyCauseInstanceof ( error , constructor ) { let currentError = error ; while ( currentError != null ) { if ( currentError instanceof constructor ) { return true ; } currentError = causeOf ( currentError ) ; } return false ; }