UNPKG

@typed/effects

Version:

Generator-powered Effect management

19 lines 687 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.catchFailure = exports.fail = void 0; const env_1 = require("@typed/env"); const maybe_1 = require("@typed/maybe"); const runWith_1 = require("../run/runWith"); const Failure_1 = require("./Failure"); function* fail(errorType, error) { return yield (c) => c[errorType](error); } exports.fail = fail; function catchFailure(effect, errorType, onError) { const failEnv = { [errorType]: (e) => env_1.Resume.of(Failure_1.Failure.of(e, maybe_1.Just.of(onError(e)))), }; return runWith_1.runWith(effect, failEnv); } exports.catchFailure = catchFailure; //# sourceMappingURL=fail.js.map