Effect CommunityEC
Effect Community9mo ago
4 replies
Dave Meehan

How to get error message from ConfigError that might be a compound (nonEmptyString)

I'm writing a HTTP response handler, which needs its database name from the environment, so I used Config.nonEmptyString('...'). All good so far.

When the config is missing, I want to return a 500 Server Error which contains a body that includes the error:

Effect.fail({ error: true, message: error.message })


I'm doing a catchTag('ConfigError', err => ...) but err is of type ConfigError which includes types And and Or which don't include a message attribute. Using type guards to discriminate between them seems long winded, and from the source I see the ConfigErrorReducer interface and the reduceWithContext method, but no actual exported reducer or way to use them (if this is even the way to do so).
Was this page helpful?