added implementation to prettify error message as middleware
Codecov Report
Merging #1334 (101b874) into main (66b571c) will increase coverage by
0.05%. The diff coverage is65.71%.
@@ Coverage Diff @@
## main #1334 +/- ##
==========================================
+ Coverage 60.79% 60.84% +0.05%
==========================================
Files 71 71
Lines 2482 2498 +16
Branches 84 78 -6
==========================================
+ Hits 1509 1520 +11
- Misses 973 978 +5
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...ttp/src/main/scala/zhttp/http/middleware/Web.scala | 72.05% <58.62%> (-10.00%) |
:arrow_down: |
| zio-http/src/main/scala/zhttp/http/Response.scala | 78.33% <100.00%> (-3.36%) |
:arrow_down: |
| ...io-http/src/main/scala/zhttp/service/Handler.scala | 80.95% <100.00%> (+7.03%) |
:arrow_up: |
| zio-http/src/main/scala/zhttp/html/Elements.scala | 22.48% <0.00%> (-1.56%) |
:arrow_down: |
| zio-http/src/main/scala/zhttp/http/Http.scala | 63.55% <0.00%> (+0.44%) |
:arrow_up: |
| .../scala/zhttp/http/headers/HeaderConstructors.scala | 27.05% <0.00%> (+1.17%) |
:arrow_up: |
| .../main/scala/zhttp/http/headers/HeaderGetters.scala | 34.95% <0.00%> (+1.62%) |
:arrow_up: |
| zio-http/src/main/scala/zhttp/http/Status.scala | 95.93% <0.00%> (+2.43%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us.
There are some places in the Handler also where we catch exceptions and create a 500 exception. Ideally, those too should handled by this middleware, otherwise we will have a bit of inconsistent way to display error messages.
There are some places in the
Handleralso where we catch exceptions and create a 500 exception. Ideally, those too should handled by this middleware, otherwise we will have a bit of inconsistent way to display error messages.
@tusharmath the error handling in Handler are happening after the HttpApp has been evaluated, so the middleware execution has been completed (unsafeRun completed). One way to unify both parts will be to migrate the formatting code to a different place (outside middleware implementation) and re-use it in Handler. To implement this it will require to know in the Handler if the middleware is in the pipeline or not.
Closing this in favor of #1492