import { bindErrorRecovery } from "https://deno.land/x/dtils@2.4.0/errors.ts";
Bind error recovery to fn
, which is expected to be a function. If when the function is later called and errors,
recoverWith
will be returned instead.
Examples:
function foo() {
throw new Error('I throw')
}
const safeFoo = bindErrorRecovery(foo, null)
foo() // Error: I throw
safeFoo() // null