As you see (green line) the flow is such that the insert if followed by an update.
What is the best way to stop the flow if there is an error in the insert?
I tried adding a function after the insert node but that did not work. I also used a catch set to detect an error on "SHRDGUI Insert" node but did not work for me.
May be I'm going into this in the wrong way.
Any ideas?
please cause 1 msg to cause 1 insert error and show BOTH debug nodes output expanded so I can decern what is happening.
In short, I want to see if 1 msg (that causes an insert error) outputs BOTH ports of the DB node AND see if there is anything in them that would allow you to check (and halt) the flow of the msg.
No, that is not how Node-RED works. Messages are passed down the wires. Either disconnect the wire (design time / no good here) or halt the msg flow (using something like a function node to return null or switch node that evaluates a non true condition)
So, if the msg leaves the bottom port ONLY, the top port never releases a message so will never travel down the wires (that you highlighted in green) - there is no message to stop (it was never emitted)
Then, thinking about it. One would think that if there is no output nothing should travel down the wire to trigger the next action.
So, with that thought I disconnected the output of the insert node and ... it continues to process the update.
I then realized that the data for the update joins from the counter branch.
At first I thought it was JUST a counter but it will push data through.
Is is possible to use a catch node and then read it from a function? If that is possible then a function between the Graduates counter and the Graduation updates function should do the trick.
When there are no errors pass the data through but on error return null. What do you think?
Actually I could even use the Graduation Updates to read for the error and handle it right there, if there is a way to read the catch node for errors.
Actually I just found a solution inside NR. Using a global variable "withErrors" and the function Graduation Updates. If the insert node throws an error, then it sets the global. I then read the global variable (if it is set) in the function and return none if it is, otherwise I carry on as I should. It worked a treat!
Thanks for your reply.