UNPKG

@typed/effects

Version:

Generator-powered Effect management

14 lines 476 B
import { Resume } from '@typed/env'; import { Just } from '@typed/maybe'; import { runWith } from '../run/runWith'; import { Failure } from './Failure'; export function* fail(errorType, error) { return yield (c) => c[errorType](error); } export function catchFailure(effect, errorType, onError) { const failEnv = { [errorType]: (e) => Resume.of(Failure.of(e, Just.of(onError(e)))), }; return runWith(effect, failEnv); } //# sourceMappingURL=fail.js.map