-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIO-based handlers produce Route.Handled
#2580
Comments
/bounty $50 |
💎 $50 bounty created by ZIO
|
💡 @987Nabil submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
🎉🎈 @987Nabil has been awarded $50! 🎈🎊 |
hey all, I've got an interesting problem with this thingie fixed. So what we're doing is manually handling defects on routes like routes.handleErrorCauseZIO(handleError) where routes can have an error of type say private def handleError(cause: Cause[Throwable]): UIO[Response] =
cause.squash match {
case error: Errors => ZIO.succeed(toResponse(error))
case defect => ZIO.logErrorCause("Endpoint failure", cause).as(toResponse(internalServerError(defect.getMessage)))
} When creating a route for these Well the problem arises due to the fact that the route with no Error happens to be
For now I was able to fix it by explicitly passing an error like |
Describe the bug
Creating routes with UIO-based handlers produces instances of
Route.Handled
, thus making custom error handling viahandleErrorCause
orhandleErrorCauseZIO
impossible (e.g., logging the defects, custom error responses, etc.).To Reproduce
Here's a minimal reproducer:
Expected behaviour
While the users can mitigate the issue by using one of
Handler
's constructors and specifying an error type manually, I would expect thathandleErrorCause*
methods are applicable by default, especially since their docs say:The text was updated successfully, but these errors were encountered: