Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgfraser committed Oct 10, 2023
1 parent 670a1d6 commit d723896
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,22 @@ final case class Endpoint[PathInput, Input, Err, Output, Middleware <: EndpointM
)

val handler =
handlers.tail.foldLeft(handlers2.head._1) { case (acc, (handler, condition)) =>
acc.catchAllCause { cause =>
if (condition(cause)) {
handler
} else {
Handler.failCause(cause)
handlers.tail
.foldLeft(handlers2.head._1) { case (acc, (handler, condition)) =>
acc.catchAllCause { cause =>
if (condition(cause)) {
handler
} else {
Handler.failCause(cause)
}
}
}
}.catchAllCause {
case cause if isHttpCodecError(cause) =>
Handler.succeed(zio.http.Response(status = Status.BadRequest))
.catchAllCause {
case cause if isHttpCodecError(cause) =>
Handler.succeed(zio.http.Response(status = Status.BadRequest))

case cause => Handler.failCause(cause)
}
case cause => Handler.failCause(cause)
}

Route.handled(self.route)(handler)
}
Expand Down

0 comments on commit d723896

Please sign in to comment.