Skip to content
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

Closed
mijicd opened this issue Jan 3, 2024 · 4 comments · Fixed by #2596
Closed

UIO-based handlers produce Route.Handled #2580

mijicd opened this issue Jan 3, 2024 · 4 comments · Fixed by #2596
Labels
💎 Bounty bug Something isn't working 💰 Rewarded

Comments

@mijicd
Copy link
Member

mijicd commented Jan 3, 2024

Describe the bug

Creating routes with UIO-based handlers produces instances of Route.Handled, thus making custom error handling via handleErrorCause or handleErrorCauseZIO impossible (e.g., logging the defects, custom error responses, etc.).

To Reproduce

Here's a minimal reproducer:

import zio._
import zio.http._

val route = Method.GET / "test" -> handler((req: Request) => ZIO.debug(s"Received $req").as(Response.ok))

println(route)

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 that handleErrorCause* methods are applicable by default, especially since their docs say:

Handles all typed errors, as well as all non-recoverable errors, by converting them into responses.
@mijicd mijicd added the bug Something isn't working label Jan 3, 2024
@jdegoes
Copy link
Member

jdegoes commented Jan 6, 2024

/bounty $50

Copy link

algora-pbc bot commented Jan 6, 2024

💎 $50 bounty created by ZIO
🙋 If you start working on this, comment /attempt #2580 to notify everyone
👉 To claim this bounty, submit a pull request that includes the text /claim #2580 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to zio/zio-http!

Attempt Started (GMT+0) Solution
🟢 @987Nabil #2596

Copy link

algora-pbc bot commented Jan 7, 2024

💡 @987Nabil submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Jan 7, 2024

🎉🎈 @987Nabil has been awarded $50! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty bug Something isn't working 💰 Rewarded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants