Handling ParseErrors in Effect Typescript HttpApi without per-handler wrapping?
Hi! I'm building an HttpApi where virtually every endpoint calls Schema.decode internally to validate database results before returning domain models. This means repository methods can fail with
The issue:
This works but requires wrapping every repository call with mapParseError.
Question: Is there a way to handle ParseErrors globally in the HttpApi without per-handler wrapping? Is there any other pattern y'all are using for this?
Should I make a new
ParseError.The issue:
ParseError isn't a schema and can't be serialized by the api. There is an existing pattern to map them into schemas like in HttpApiDecodeError.fromParseError, but using this requires me to wrap very endpoint in an error mapper:This works but requires wrapping every repository call with mapParseError.
Question: Is there a way to handle ParseErrors globally in the HttpApi without per-handler wrapping? Is there any other pattern y'all are using for this?
Should I make a new
Schema.decode that fails with my own ParseErrorSchema and use that everywhere?