Add tapErrorZIO and tapErrorCauseZIO to Route and Routes
Useful for things like error logging or reporting to external services such as Sentry.
Codecov Report
Attention: Patch coverage is 0% with 10 lines in your changes are missing coverage. Please review.
Project coverage is 64.34%. Comparing base (
709b459) to head (006b320).
| Files | Patch % | Lines |
|---|---|---|
| ...io-http/shared/src/main/scala/zio/http/Route.scala | 0.00% | 8 Missing :warning: |
| ...o-http/shared/src/main/scala/zio/http/Routes.scala | 0.00% | 2 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## main #2755 +/- ##
==========================================
- Coverage 64.42% 64.34% -0.08%
==========================================
Files 148 148
Lines 8668 8678 +10
Branches 1589 1545 -44
==========================================
Hits 5584 5584
- Misses 3084 3094 +10
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thanks for the feedback!
@tjarvstrand Could you handle the review comments? I'd like to get this in for 3.0
The tests seem to fail on something unrelated to my changes. Not sure if it's a fluke but I don't seem to be allowed to restart the workflow.
I updated your branch. Let's see if it builds
Please add some tests. For example adding a log output and use the test logger to find the message you logged. Or use a promise. Or whatever comes to your mind :)
@tjarvstrand could you give this PR the finishing touch? :)
Looking into writing some tests ATM. In the meantime, I think I'm lacking the context needed to make wise decisions on my own here 😄
Just to make sure I don't misunderstand, you are saying that I should basically just return the same Handled value on both what is currently line 172 and 197? E.g.:
final def tapErrorCauseZIO[Err1 >: Err](
f: Cause[Err] => ZIO[Any, Err1, Any],
)(implicit trace: Trace, ev: CheckResponse[Err]): Route[Env, Err1] =
self match {
case Provided(route, env) => Provided(route.tapErrorCauseZIO(f), env)
case Augmented(route, aspect) => Augmented(route.tapErrorCauseZIO(f), aspect)
case handled @ Handled(_, _, _) => handled
case Unhandled(rpm, handler, zippable, location) =>
Unhandled(rpm, handler.tapErrorCauseZIO(f), zippable, location)
}
EDIT: I think I figured most of it out. Everything became clearer once my mind got back into "scala mode". Please have another look.
However, I noticed that the handler of an Unhandled doesn't seem to be evaluated. Should that case also just return the same value?