Error Propagation
use
import { Result } from 'funkcia';
declare const safeParseInt: (string: string, radix?: number) => Result<number, TypeError>;
// ┌─── Result<number, TypeError>
// ▼
const result = Result.use(function* () {
const x = yield* safeParseInt('10');
const y = yield* safeParseInt('invalid'); // breaks the circuit, returning Result.Error
return Result.ok(x + y); // doesn't run
});
// Output: Error(TypeError)fn
Understanding the use method
Last updated
Was this helpful?