export const syncFunctionThatCanFail = () => {
if (Math.random() > 0.5) {
return Effect.fail(new FileCountMismatch("image", 5, 10));
}
return Effect.succeed(null);
};
// This doesn't work as the return is a union of effects
syncFunctionThatCanFail().pipe(Effect.catchTag(/* red squgglies cause of never type */))
// so we have to wrap it in Effect.unified everytime we call the function
Effect.unified(syncFunctionThatCanFail()).pipe(Effect.catchTag("MyErrorTag"));
export const syncFunctionThatCanFail = () => {
if (Math.random() > 0.5) {
return Effect.fail(new FileCountMismatch("image", 5, 10));
}
return Effect.succeed(null);
};
// This doesn't work as the return is a union of effects
syncFunctionThatCanFail().pipe(Effect.catchTag(/* red squgglies cause of never type */))
// so we have to wrap it in Effect.unified everytime we call the function
Effect.unified(syncFunctionThatCanFail()).pipe(Effect.catchTag("MyErrorTag"));