The example repository RepositoriesElasticsearch still maps validation failures to IllegalArgumentException:
private def routingOf(value: String): IO[IllegalArgumentException, Routing.Type] =
Routing.make(value).toZIO.mapError(e => new IllegalArgumentException(e))
-
Suggested Approach:
- Introduce a domain error ADT for routing failures (e.g., sealed trait RoutingError with a InvalidRouting case).
- Update routingOf to return IO[RoutingError, Routing.Type] and map the validation message into that error.
- Adjust public APIs (create, findById, etc.) and tests/examples to reflect the new error type.
-
Acceptance Criteria:
- No IllegalArgumentException remains in the example module for routing validation.
- New domain error type(s) in example app.
- Tests/examples compile and demonstrate the typed error channel.