Effect CommunityEC
Effect Community2w ago
2 replies
Semaelse

Mapping Specific Errors with Effect.catchSome

Is there an easier way to map/catch only some errors and then map all remaing to a generic error?

 Effect.catchSome((e) => {
    // Handle specific error type
    if (e._tag === "adapters/InvalidApiKeyError") {
      return Option.some(
        Effect.fail(new InvalidExternalApiKeyError({ cause: e }))
      );
    }
    // Let other errors fall through to catchAll
    return Option.none();
  }),
  Effect.catchAll((e) => new InternalError({ cause: e }))


And here I think still InvalidExternalApiKeyError get's mapped to InternalError
Was this page helpful?