Error Handling Strategy for Browser Client SDK Using Effect Library

just a question on the error handling front, would this be the most appropriate way to go about this? this is part of an sdk consumed on a browser client. its either there in a valid state or not, I log any errors before clearing for good measure (if somehow it fails decoding)

export const makeLiveSessionStore = Effect.gen(function* () {
  const config = yield* ConfigStore;
  const storage = yield* KeyValueStore.KeyValueStore;
  const sessionStorage = storage.forSchema(Session);

  const clear = pipe(sessionStorage.clear, Effect.ignore);

  const current = pipe(
    sessionStorage.get(config.sessionKey),
    Effect.tap(Option.match({
      onNone: () => Effect.logInfo("No session retrieved."),
      onSome: (session) => Effect.logInfo(`Session ${session.id} retrieved.`),
    })),
    Effect.map(Option.getOrNull),
    Effect.tapErrorCause((cause) => Effect.logError(Cause.pretty(cause))),
    Effect.catchAll(() => pipe(clear, Effect.map(constNull))),
  );

  // ...rest of code
Was this page helpful?