Skip to content

Commit

Permalink
fix: catch malformated message
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Stoffel committed Sep 20, 2024
1 parent b88e6b9 commit d221880
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions node-red-contrib-c8y-client/src/nodes/notification/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,22 @@ module.exports = function (RED) {
node.debug(
`New Notification id: ${id} source: ${source} operation: ${operation} \n payload: ${payload}`
);
const msg = {
payload: {
id: id,
source: source,
operation: operation,
message: JSON.parse(payload),
},
};
let msg;
try {
msg = {
payload: {
id: id,
source: source,
operation: operation,
message: JSON.parse(payload),
},
};
} catch (error) {
node.error(
`[ws error] parsing payload ${error}`
);
return;
}
// Ack message
try {
node.socket.send(id);
Expand Down

0 comments on commit d221880

Please sign in to comment.