Creating an Auth Guard Function with Error Handling in Effect Typescript

trying to create a function that handles catching certain errors. e.g. an auth guard that catches some auth related errors

type SessionErrors = SessionNotFound | SessionNotRetrievable;

export function authGuard<A, E extends SessionErrors, R>(effect: Effect.Effect<A, E, R>) {
    return effect.pipe(
        Effect.catchTags({
            SessionNotFound: () => Effect.succeed(<p>Session not found </p>),
            SessionNotRetrievable: () =>
                Effect.succeed(<p>Session not retrievable </p>),
        }),
    );
}


Struggling to ensure that the passed effect includes the session errors and has them not being handled yet.

Any ideas?
Was this page helpful?