import { Data, Effect } from 'effect';
class BackgroundJobError extends Data.TaggedError('BackgroundJobError')<{ error: Error }> {}
const program = Effect.gen(function* (_) {
console.log('print hello');
yield* _(
Effect.tryPromise({
try: async () => await job.send(),
catch: (error) => new BackgroundJobError({ error: unknownToError(error) }),
}),
);
/**
* I need this program to return even if sending the job fails
* because I don't want this error to be visible to the end user.
*/
return 'everything is fine meme';
});
// I don't want the failed effect to show up in the error channel of Either
Effect.runPromise(program.pipe(Effect.either));
import { Data, Effect } from 'effect';
class BackgroundJobError extends Data.TaggedError('BackgroundJobError')<{ error: Error }> {}
const program = Effect.gen(function* (_) {
console.log('print hello');
yield* _(
Effect.tryPromise({
try: async () => await job.send(),
catch: (error) => new BackgroundJobError({ error: unknownToError(error) }),
}),
);
/**
* I need this program to return even if sending the job fails
* because I don't want this error to be visible to the end user.
*/
return 'everything is fine meme';
});
// I don't want the failed effect to show up in the error channel of Either
Effect.runPromise(program.pipe(Effect.either));