From 3b01a8baa57ef038eb836260636be926a33ca728 Mon Sep 17 00:00:00 2001 From: windka Date: Tue, 2 Jul 2024 23:26:11 +0200 Subject: [PATCH] tried to fix unhandled exception in sender node --- CHANGELOG.md | 5 ++++- package.json | 2 +- telegrambot/99-telegrambot.js | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e46de9..3e30ed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. -# [16.0.0] - 2024-06-22 +# [16.0.2] - 2024-07-02 +### tried to fix unhandled exception in sender node - [#377](https://github.com/windkh/node-red-contrib-telegrambot/issues/377) + +# [16.0.1] - 2024-06-22 ### fixed getFile typo - [#381](https://github.com/windkh/node-red-contrib-telegrambot/issues/381) # [16.0.0] - 2024-06-21 diff --git a/package.json b/package.json index b021515..39fa850 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-telegrambot", - "version": "16.0.1", + "version": "16.0.2", "description": "Telegram bot nodes for Node-RED", "dependencies": { "bluebird": "^3.7.2", diff --git a/telegrambot/99-telegrambot.js b/telegrambot/99-telegrambot.js index 7cba939..b5ebc1a 100644 --- a/telegrambot/99-telegrambot.js +++ b/telegrambot/99-telegrambot.js @@ -1635,7 +1635,12 @@ module.exports = function (RED) { this.processError = function (exception, msg) { let errorMessage = 'Caught exception in event node:\r\n' + exception + '\r\nwhen processing message: \r\n' + JSON.stringify(msg); node.error(errorMessage, msg); - throw exception; + + node.status({ + fill: 'red', + shape: 'ring', + text: exception.message, + }); }; this.start = function () { @@ -2093,18 +2098,23 @@ module.exports = function (RED) { this.processError = function (exception, msg, nodeSend, nodeDone) { let errorMessage = 'Caught exception in sender node:\r\n' + exception + '\r\nwhen processing message: \r\n' + JSON.stringify(msg); + node.status({ + fill: 'red', + shape: 'ring', + text: exception.message, + }); + if (haserroroutput) { let sendMessage = RED.util.cloneMessage(msg); sendMessage.error = errorMessage; nodeSend([null, sendMessage]); } else { if (nodeDone) { + node.error(errorMessage, msg); nodeDone(errorMessage); } else { node.error(errorMessage, msg); } - - throw exception; } }; @@ -2114,6 +2124,7 @@ module.exports = function (RED) { msg.payload.sentMessageId = result.message_id; nodeSend(msg); } + if (nodeDone) { nodeDone(); }