Skip to content

Commit

Permalink
forward port of: #16261
Browse files Browse the repository at this point in the history
  • Loading branch information
BryceStansfieldAt-da committed Mar 7, 2023
1 parent 39d816f commit 072d97c
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ class Endpoints(
output.map(_.fold(httpResponseError, identity))
}

private def searchHttpResponse(searchResult: SearchResult[Error \/ JsValue]): HttpResponse = {
import json.JsonProtocol._
private def searchHttpResponse(
searchResult: SearchResult[Error \/ JsValue]
)(implicit lc: LoggingContextOf[RequestID]): HttpResponse = { import json.JsonProtocol._

val response: Source[ByteString, NotUsed] = searchResult match {
case domain.OkResponse(result, warnings, _) =>
Expand All @@ -421,9 +422,17 @@ class Endpoints(
)
}

private[this] def filterStreamErrors[E, A]: Flow[Error \/ A, Error \/ A, NotUsed] =
private[this] def filterStreamErrors[A](implicit
lc: LoggingContextOf[RequestID]
): Flow[Error \/ A, Error \/ A, NotUsed] =
Flow[Error \/ A].map {
case -\/(ServerError(_)) => -\/(ServerError.fromMsg("internal server error"))
case -\/(ServerError(t)) =>
val hideMsg = "internal server error"
logger.error(
s"hiding internal error details from response, responding '$hideMsg' instead",
t,
)
-\/(ServerError.fromMsg(hideMsg))
case o => o
}

Expand Down

0 comments on commit 072d97c

Please sign in to comment.