node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

I need error msg

Open tamasvar opened this issue 2 years ago • 4 comments

I still need the msg.payload when there is an error, not only when everything is going well.

  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)

Proposed changes

Checklist

  • [ ] I have read the contribution guidelines
  • [ ] For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • [ ] I have run grunt to verify the unit tests pass
  • [ ] I have added suitable unit tests to cover the new/changed functionality

tamasvar avatar Jan 11 '23 07:01 tamasvar

CLA Not Signed

I can understand why you may want it - but for naive users I think it is better to not send anything when there is an error, rather than send a (normally) empty [] response that would look like a valid response unless you check for an error. So I'm not (yet) convinced that this a change we should make. You could also use the error to create a dummy payload [] if you need to forward it on - but yes your fix would do that for you.

dceejay avatar Jan 17 '23 17:01 dceejay

I can understand why you may want it - but for naive users I think it is better to not send anything when there is an error, rather than send a (normally) empty [] response that would look like a valid response unless you check for an error. So I'm not (yet) convinced that this a change we should make. You could also use the error to create a dummy payload [] if you need to forward it on - but yes your fix would do that for you.

I agree that it shouldn't send an error but I do think it should throw an error

shaqaruden avatar Feb 01 '23 15:02 shaqaruden

I would suggest a slightly different approach - with largely the same result. Create a secondary output, which is used in case of error. In 64-mysql.html change: outputs:1, to outputs:2, In 68-mysql.js After the line (147) node.error(err, msg); add line: send([null, { query: msg.topic, payload: 'ERROR', error: err }]);

You could event remove the node.error() - if you wanted it to be less chatty

I created a PR: https://github.com/node-red/node-red-nodes/pull/1062

jonbdk avatar Apr 22 '24 23:04 jonbdk