From e2252f7e87593aa876ecec53e694ecdd76fbd9cc Mon Sep 17 00:00:00 2001 From: John McKerrell Date: Thu, 6 Aug 2020 13:54:08 +0100 Subject: [PATCH] Update 27-twitter.js Improve the error handling around posting to twitter. --- social/twitter/27-twitter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js index 555d56179..23245426c 100644 --- a/social/twitter/27-twitter.js +++ b/social/twitter/27-twitter.js @@ -642,7 +642,13 @@ module.exports = function(RED) { node.status({}); } else { node.status({fill:"red",shape:"ring",text:"twitter.status.failed"}); - node.error(result.body.errors[0].message,msg); + if (result.body.errors && result.body.errors[0] && result.body.errors[0].message) { + node.error(result.body.errors[0].message,msg); + } else if (result.body.error) { + node.error(result.body.error,msg); + } else { + node.error("Twitter gave status: "+result.status+", unexpected body: "+JSON.stringify(result.body),msg); + } } }).catch(function(err) { node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});