You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2021/01/06 14:45:58 UTC

[openwhisk-client-go] branch master updated: update status code if action returns error (#142)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 17d5563  update status code if action returns error (#142)
17d5563 is described below

commit 17d556327cd39cb6d6854667fa75c35ef9f2e6f1
Author: ShubhamGupta9582 <30...@users.noreply.github.com>
AuthorDate: Wed Jan 6 20:15:48 2021 +0530

    update status code if action returns error (#142)
---
 whisk/activation.go | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/whisk/activation.go b/whisk/activation.go
index 0204dba..fdbe40c 100644
--- a/whisk/activation.go
+++ b/whisk/activation.go
@@ -216,9 +216,28 @@ func (s *ActivationService) Get(activationID string) (*Activation, *http.Respons
 		return nil, resp, err
 	}
 
+	a.StatusCode = GetStatusCodeForMessage(a.Status)
+
 	return a, resp, nil
 }
 
+func GetStatusCodeForMessage(msg string) int {
+	var code int
+
+	switch msg {
+	case "application error":
+		code = 1
+	case "action developer error":
+		code = 2
+	case "whisk internal error":
+		code = 3
+	default:
+		code = 0
+	}
+
+	return code
+}
+
 func (s *ActivationService) Logs(activationID string) (*Activation, *http.Response, error) {
 	// TODO :: for some reason /activations/:id/logs only works with "_" as namespace
 	s.client.Namespace = "_"