mySql warn/error and Catch node

293 views
Skip to first unread message

Sinusoidal

unread,
Nov 1, 2015, 5:27:29 AM11/1/15
to Node-RED
Hi, 

I've been using the mysql node a bit recently. I came across a problem that (if I have understood correctly) Dave has touched on before (https://groups.google.com/d/msg/node-red/JtzNMLN2NpA/vU9SkvK3HwAJ). In my database I have set a column to have a unique value. Consequently, attempts to feed a duplicate value into the table are rejected by the database. The problem is that no error is thrown here - in the code, it's clearly a node.warn that is used. Because of this, I can't Catch the error and respond accordingly. 

To me, my flow makes good sense; the duplicate entry situation is an exceptional circumstance so seems to be appropriate for this kind of Catch-behaviour. 

Ok, so the second part of this is that even if I go in and edit the mysql node (ln 106) to node.error instead of node.warn, I still don't Catch anything in my Catch-node. The debug shows that I've successfully changed node.warn to node.error, though. What am I missing, I wonder? The Catch node is on the same tab, I've also tried hooking it directly up to the mysql node.

Thanks!

/Alan

Nicholas O'Leary

unread,
Nov 1, 2015, 5:31:39 AM11/1/15
to Node-RED

To trigger the catch node, you have to pass a message object as the second argument to the call to .error, which is what arrives at the Catch node. Calling it with just the error text just causes the error to be logged.

http://nodered.org/docs/creating-nodes/node-js.html#handling-errors

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Nov 1, 2015, 5:33:26 AM11/1/15
to node...@googlegroups.com

​and yes we should fix... (the one line reply on that original post was probably me replying from phone and then forgetting to add to to-do list... what with 5th Aug being summer vacation...)

Sinusoidal

unread,
Nov 1, 2015, 5:40:40 AM11/1/15
to Node-RED
Thanks, both of you. You always answer so fast :) I just discovered this in the docs and came back in to update. So I can patch it in the meantime, that's the main thing for now. Perhaps it would be worth mentioning the second argument in the Catch node docs too.

Dave C-J

unread,
Nov 1, 2015, 6:13:55 AM11/1/15
to node...@googlegroups.com
:-)

let us know if it works... and I'll patch it up this end. 
I assume L106 is now like
if (err) { node.error(err,msg); }  ???

Sinusoidal

unread,
Nov 1, 2015, 3:38:22 PM11/1/15
to Node-RED
Works fine! And yes, that's what I have too.

Dave C-J

unread,
Nov 1, 2015, 4:41:46 PM11/1/15
to node...@googlegroups.com
great - now updated on npm to 0.0.7 also
Reply all
Reply to author
Forward
0 new messages