update status code if action returns error (#142)
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 @@
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 = "_"