openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk-package-cloudant] branch master updated: check if we should disable trigger for status codes on error object (#190)
Date Tue, 18 Dec 2018 03:31:43 GMT
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-cloudant.git


The following commit(s) were added to refs/heads/master by this push:
     new f047b94  check if we should disable trigger for status codes on error object (#190)
f047b94 is described below

commit f047b94f77c5ee06998fc3963e22d99bb8948e32
Author: Jason Peterson <jasonpet@us.ibm.com>
AuthorDate: Mon Dec 17 22:31:40 2018 -0500

    check if we should disable trigger for status codes on error object (#190)
---
 provider/lib/utils.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/provider/lib/utils.js b/provider/lib/utils.js
index 214c6e5..26b62b7 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -250,11 +250,15 @@ module.exports = function(logger, triggerDB, redisClient) {
                             triggerData.triggersLeft++;
                         }
                         logger.error(method, 'there was an error invoking', triggerData.id,
statusCode || error);
-                        if (!error && shouldDisableTrigger(statusCode)) {
-                            //disable trigger
-                            var message = 'Automatically disabled after receiving a ' + statusCode
+ ' status code when firing the trigger';
-                            disableTrigger(triggerData.id, statusCode, message);
-                            reject('Disabled trigger ' + triggerData.id + ' due to status
code: ' + statusCode);
+                        if (statusCode && shouldDisableTrigger(statusCode)) {
+                            var message;
+                            try {
+                                message = error.error.errorMessage;
+                            } catch (e) {
+                                message = `Received a ${statusCode} status code when firing
the trigger`;
+                            }
+                            disableTrigger(triggerData.id, statusCode, `Trigger automatically
disabled: ${message}`);
+                            reject(`Disabled trigger ${triggerData.id}: ${message}`);
                         }
                         else {
                             if (retryCount < retryAttempts ) {


Mime
View raw message