-
Notifications
You must be signed in to change notification settings - Fork 14
properly throw errors so Catch node can handle them. #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trophy, sorry for the late reply.
I haven't heard of this catch node before. Thank you for making the effort to update the code to collaborate with this framework.
Have you tested your changes to make sure they work as they should? And nothing breaks?
Thanks
@smchamberlin I have been using the patched version in my project for a month and it worked fine so far. In terms of "breaking changes", there is one thing worth mentioning: when errors happen, the node need to decide whether:
The PR added (1) in all error workflows, which is fine. The PR tries to be consistent that the node "terminates the flow" in all error cases (mainly https://github.com/smchamberlin/node-red-nodes-cf-sqldb-dashdb/pull/21/files#diff-6a9587bbfd51a40c36f0ab107ab1e3b1R212), but this can be a breaking changes if a workflow assumes the node will always send output in 98-sqldb-dashdb-cf.js#L353 even when error happens. Do you have any thoughts on what we want to define behavior in the case of (2) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good, just have one question where a try/catch was removed. Thanks!
@@ -149,16 +154,10 @@ function getColumns (node,db,table,service) { | |||
if (removeSchema.length > 1) { table = removeSchema[1]; } | |||
console.log(service+": Fetching column names for table " + table + "..."); | |||
var sysibmColumns; | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the try/catch here ?
Currently dashdb node doesn't properly handle errors - it logs the error on console, then "swallows" it.
Impact: when errors happened in dashdb nodes, the flow simply terminates and there is no way for flow developer to handle error and recover.
The proper way to handle errors as documented in node-red official docs:
Handling errors
If the function encounters an error that should halt the current flow, it should return nothing. To trigger a Catch node on the same tab, the function should call node.error with the original message as a second argument:
This PR updates dashdb code to pass in
msg
in allnode.error()
calls so that Catch node will be able to catch those errors.