Effect CommunityEC
Effect Community3y ago
10 replies
Anna | DevMiner

Removing `<A>` from `Effect.catchTag()`

Is there a way to throw away the <A> of Effect.catchTag()?

My current code is this:
const notifier = yield* _(
    getNotifier(notification.id as NotificationId, target),
    Effect.catchTag('UserDoesntExist', (a) =>
        Effect.tryPromise({
            try: () => {
                console.log('Moving notification to admin target', a.userId);
                return prisma.notification.update({
                    where: { id: notification.id },
                    data: { target: 'ADMIN' }
                });
            },
            catch: (e) => new QueryError({ inner: e as Error })
        })
    )
);

// `notifier` now is `Notifier | Notification`, how do I prevent this?
Was this page helpful?