-
Notifications
You must be signed in to change notification settings - Fork 412
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
Add access to Env in error handler #2870
Comments
/bounty $50 |
💎 $50 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-http! Add a bounty • Share on socials
|
@jdegoes I tried this and came to have an issue with this definition of Route private final case class Augmented[InEnv, -OutEnv, +Err](
route: Route[InEnv, Err],
aspect: Handler[InEnv, Response, Request, Response] => Handler[OutEnv, Response, Request, Response],
) extends Route[OutEnv, Err] {
def location: Trace = route.location
def routePattern: RoutePattern[_] = route.routePattern
override def toHandler(implicit ev: Err <:< Response, trace: Trace): Handler[OutEnv, Response, Request, Response] =
aspect(route.toHandler)
override def toString() = s"Route.Augmented(${route}, ${aspect})"
} I think this makes it currently impossible to have the an We could restrict But I am not sure that is a good idea, because then you might need to provide |
@987Nabil Have you tried to make |
💡 @987Nabil submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
* Remove route builder * Env access in handle error (#2870)
🎉🎈 @987Nabil has been awarded $50! 🎈🎊 |
Hi!
Would it be possible to add support for accessing Env in e.g.
Routes.handleErrorRequestCauseZIO(f: (Request, Cause[Err]) => ZIO[Any, Nothing, Response]): Route[Env, Nothing]
so it becomes
Routes.handleErrorRequestCauseZIO(f: (Request, Cause[Err]) => ZIO[Env, Nothing, Response]): Route[Env, Nothing]?
It would be great to be able to get logged in user, correlation id etc when generating the error message.
Thanks!
The text was updated successfully, but these errors were encountered: