openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbic...@apache.org
Subject [incubator-openwhisk-client-go] 01/01: Parse numbers correctly in error response.
Date Thu, 26 Apr 2018 06:53:46 GMT
This is an automated email from the ASF dual-hosted git repository.

cbickel pushed a commit to branch tid
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git

commit bd6f2d9a531c1fbae8a5ac71c84ceb68b187bd71
Author: Christian Bickel <cbickel@de.ibm.com>
AuthorDate: Thu Apr 26 08:44:50 2018 +0200

    Parse numbers correctly in error response.
---
 whisk/client.go | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/whisk/client.go b/whisk/client.go
index 85ac505..f413d17 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -514,11 +514,14 @@ func parseErrorResponse(resp *http.Response, data []byte, v interface{})
(*http.
 	Debug(DbgInfo, "HTTP failure %d + body\n", resp.StatusCode)
 
 	// Determine if an application error was received (#5)
-	errorResponse := &ErrorResponse{Response: resp}
-	err := json.Unmarshal(data, errorResponse)
+    buf := bytes.NewBuffer(data)
+    d := json.NewDecoder(buf)
+    d.UseNumber()
+
+    var errorResponse := &ErrorResponse{Response: resp}
 
 	// Determine if error is an application error or an error generated by API
-	if err == nil {
+    if err := d.Decode(&errorResponse); err != nil {
 		if errorResponse.Code == nil /*&& errorResponse.ErrMsg != nil */ && resp.StatusCode
== 502 {
 			return parseApplicationError(resp, data, v)
 		} else if errorResponse.Code != nil && errorResponse.ErrMsg != nil {

-- 
To stop receiving notification emails like this one, please contact
cbickel@apache.org.

Mime
View raw message