Skip to content

Commit

Permalink
tried to fix unhandled exception in sender node
Browse files Browse the repository at this point in the history
  • Loading branch information
windka committed Jul 2, 2024
1 parent f5cf688 commit 3b01a8b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
17 changes: 14 additions & 3 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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;
}
};

Expand All @@ -2114,6 +2124,7 @@ module.exports = function (RED) {
msg.payload.sentMessageId = result.message_id;
nodeSend(msg);
}

if (nodeDone) {
nodeDone();
}
Expand Down

0 comments on commit 3b01a8b

Please sign in to comment.