You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/03/27 19:00:13 UTC

[GitHub] [incubator-openwhisk] rabbah commented on a change in pull request #4403: Add detailed error and reason information to status code

rabbah commented on a change in pull request #4403: Add detailed error and reason information to status code
URL: https://github.com/apache/incubator-openwhisk/pull/4403#discussion_r269722015
 
 

 ##########
 File path: common/scala/src/main/scala/org/apache/openwhisk/http/PoolingRestClient.scala
 ##########
 @@ -110,9 +112,17 @@ class PoolingRestClient(
       if (response.status.isSuccess) {
         Unmarshal(response.entity.withoutSizeLimit).to[T].map(Right.apply)
       } else {
-        // This is important, as it drains the entity stream.
-        // Otherwise the connection stays open and the pool dries up.
-        response.discardEntityBytes().future.map(_ => Left(response.status))
+        Unmarshal(response.entity).to[JsObject].flatMap { responseEntity =>
+          val error = responseEntity.fields.get("error").getOrElse("").toString
+          val reason = responseEntity.fields.get("reason").getOrElse("").toString
+          val statusCode = response.status
+          val statusCodeReason = statusCode.reason()
+          val customReason = s"$statusCodeReason (error: $error, reason: $reason)"
+          val customStatusCode = StatusCodes.custom(intValue = statusCode.intValue(), reason = customReason, defaultMessage = statusCode.defaultMessage())
 
 Review comment:
   What's the value of exposing all these details anyway - is the idea to surface this to the end user or logs or what?
   The runtime interface for containers doesn't require one to respond with any particular schema, beyond status code and a JSON object in the successful case.
   
   So in case of failure, it may not even be a JSON object that you get back from the proxy.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services