-
-
Notifications
You must be signed in to change notification settings - Fork 479
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Following app
//> using dep "dev.zio::zio:2.1.16"
//> using dep "dev.zio::zio-streams:2.1.16"
//> using dep "dev.zio::zio-http:3.1.0"
import zio.*
import zio.http.*
object ZioHttpIssue extends zio.ZIOAppDefault:
def causeHandler: Handler[Any, Nothing, Request, Response] = handler { (req: Request) =>
for {
hello <- ZIO.succeed("Hello")
_ = throw new IllegalArgumentException("boom")
} yield Response.text(hello)
}
def run = {
val myroutes = causeHandler.toRoutes
val app = myroutes
// comment line below resolves the issue
.handleErrorZIO(_ => ZIO.succeed(Response.text("handleErrorZIO")))
// handleErrorCauseZIO does not work also
.handleErrorCause(cause => Response.text("handleErrorCause")) // I expecting see this response
ZIO.scoped {
app.apply(Request.get("/")).tap { response =>
ZIO.debug(response)
}
} *> ZIO.debug("and now for comparison - zio behaviour") *> zioPlain
}
def zioPlain = ZIO.attempt(1)
.map(i => throw new IllegalArgumentException("boom"))
.catchAll(_ => ZIO.succeed("catchAll"))
.catchAllCause(cause => ZIO.succeed("catchAllCause")) // as expected we will see this
.debugprints
Response(InternalServerError,Headers(),Body.empty)
and now for comparison - zio behaviour
catchAllCause
But I was expecting
Response(Ok,Headers((content-type,text/plain)),Body.fromAsciiString(handleErrorCause))
for zio-http part
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working