csantanapr closed pull request #173: check if we should disable trigger for status codes on error object URL: https://github.com/apache/incubator-openwhisk-package-alarms/pull/173
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/provider/lib/utils.js b/provider/lib/utils.js index 6dde7ef..943dbe2 100644 --- a/provider/lib/utils.js +++ b/provider/lib/utils.js @@ -113,11 +113,15 @@ module.exports = function(logger, triggerDB, redisClient) { triggerData.triggersLeft++; } - if (!error && shouldDisableTrigger(statusCode)) { - //disable trigger - var message = 'Automatically disabled after receiving a ' + statusCode + ' status code when firing the trigger'; - disableTrigger(triggerIdentifier, statusCode, message); - reject('Disabled trigger ' + triggerIdentifier + ' 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(triggerIdentifier, statusCode, `Trigger automatically disabled: ${message}`); + reject(`Disabled trigger ${triggerIdentifier}: ${message}`); } else { if (retryCount < retryAttempts) { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services