fp-ts: `either.tryCatch`: `onerror` param?
task.tryCatch
has an onrejected
param. This is useful because it allows you to define the type of the error:
export declare const tryCatch: <L, A>(f: Lazy<Promise<A>>, onrejected: (reason: {}) => L) => Task<Either<L, A>>;
However, either.tryCatch
does not have this. Instead, it assumes the error type will be Error
—but as we know, that’s not always the case in JS!
Would you accept a PR to add an onerror
param to either.tryCatch
?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (3 by maintainers)
Commits related to this issue
- New Feature: add an optional `onerror` argumento to `Either.tryCatch`, fix #323 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: add an optional `onerror` argument to `Either.tryCatch`, fix #323 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: add an optional `onerror` argument to `Either.tryCatch`, fix #323 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: add an optional `onerror` argument to `Either.tryCatch`, fix #323 — committed to gcanti/fp-ts by gcanti 6 years ago
What about
This is backward compatible, has a handy default (for interop with sane libraries), solves the existing bug and allows for custom refinements