Skip to content

Replace IllegalArgumentException in example app with Domain Error #705

@dbulaja98

Description

@dbulaja98

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:

    1. Introduce a domain error ADT for routing failures (e.g., sealed trait RoutingError with a InvalidRouting case).
    2. Update routingOf to return IO[RoutingError, Routing.Type] and map the validation message into that error.
    3. Adjust public APIs (create, findById, etc.) and tests/examples to reflect the new error type.
  • Acceptance Criteria:

    1. No IllegalArgumentException remains in the example module for routing validation.
    2. New domain error type(s) in example app.
    3. Tests/examples compile and demonstrate the typed error channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions