1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Update 27-twitter.js

Improve the error handling around posting to twitter.
This commit is contained in:
John McKerrell 2020-08-06 13:54:08 +01:00 committed by GitHub
parent 81039eacbc
commit e2252f7e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -642,7 +642,13 @@ module.exports = function(RED) {
node.status({}); node.status({});
} else { } else {
node.status({fill:"red",shape:"ring",text:"twitter.status.failed"}); 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) { }).catch(function(err) {
node.status({fill:"red",shape:"ring",text:"twitter.status.failed"}); node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});