Handling Config Errors in Layered App with Effect TypeScript

👋 I'm building an app that has 3 layers, and one of those layers is using some Config values e.g (const accountSid = yield* Config.string("TWILIO_ACCOUNT_SID"))

This config could raise an error, but when I'm using this layer as a dependency of another layer, the Error is not available in the main Effect. I don't know how to make the code aware of
the config error in the main effect.

The returned type for the program is
Effect.Effect<Message, HttpClientError | ParseError, TwilioNetwork>

The TwilioNetwork is the layer that contains the ConfigError that's not being exposed
Effect.Effect<HttpClientRequest.HttpClientRequest, ConfigError, TwilioApiUrl>


// index.ts
const main = program.pipe(
    Effect.catchTags({
      ParseError: (error) => {
        return Effect.succeed(`ParseError: ${error.message}`);
      },
      RequestError: (error) => {
        return Effect.succeed(`RequestError: ${error.message}`);
      },
      ResponseError: (error) => {
        return Effect.succeed(`ResponseError--: ${JSON.stringify(error)}`);
      },
      // Config Error is not here.
      // ConfigError: (error) => {
      //   return Effect.succeed(`ConfigError: ${error.message}`);
      // }
    })

Do I need to catch the error inside the layer? I'm a bit lost here. Thanks for your help!
Was this page helpful?