Getting errors to the server side in UI node

Hi folks,

the 2.0 release of the SVG UI node is almost completed, but would like to have a better error logging mechanism. Currently the errors are written to the console log on the client-side (because most of the stuff happens inside the dashboard), but that is not obvious for users:

  • Not all users look in the browser console log.
  • When running the dashboard e.g. on an Android smartphone, you have no easy access to e.g. Chrome's console log (unless you setup USB debugging between two Chrome installations ...).

So we would like to get the client-side errors to the node-red flow on the server-side. But don't know how to do this:

  1. If I'm not mistaken, I can only have a single output port in a UI node (so no second output possible dedicated for error messages). Could send them on the current existing output, but then flows become more complex (to reroute the error messages) and it will break existing flows.
  2. Suppose I don't want to send error messages on the output, but e.g. call node.error(...) on the server-side. But when I send as error message from the client to the server, I could intercept that message (to call node.error) but I don't think I can avoid the message from being send on the output. So how should I send then the error info from the client to the server?

Does anybody know a better way to implement this?


re 2) why would you NOT want to call node.error - if it's an error that you want the user to know about and be able to do something with - that is what it it for. If it's not worthy of user attention then don't call it at all (or maybe just node.log it).
re 1) well there is nothing to actually stop you having a second output... but node.error is the actual mechanism for reporting errors - so why not use it ?

Hey Dave,
my brain seems to have melted by all my developments...

  • Can I simply call node.error on the client side?
  • Or do you mean that I need to send my error to the server, and call node.error there? But what is then then the best way to get the error on the server side? Because when I use $scope.send to transfer the error to the server, then that error message will be send on the output (since I thought I cannot stop it from being send)?

I'm getting the impression that I'm asking stupid questions now ...

Hey Dave,

Got something up-and-running, but I had to (ab)use an existing field...

Suppose I send an error in the client-side (dashboard), instead of a real message:

// Oeps problem detected, so let's send an error message to the server-side
$scope.send({error: "Problem detected on the server side!"});

Then that error arrives on the server-side, where I can intercept it (before it is being sent to the output):

beforeSend: function (msg, orig) {
   // When an error message is being send from the client-side, just log the error
   if (orig.msg.hasOwnProperty("error")) {
      // Dirty hack to avoid that the error message is being send on the output of this node
      orig["_fromInput"] = "dummy";
   // Otherwise manipulate the output message 

Now my error is being logged on the server-side, so the user sees immediately that he has done something wrong:


However what I don't like is that I had to abuse the _fromInput variable to fool the dashboard, in order to avoid that the message is being sent to the output:


  1. On line 285 the beforeSend function is called, where my code is executed
  2. The condition on line 288 will not be true anymore, since I filled that field
  3. This means we don't arrive on line 289, which means the message will not be sent on the output

But whenever this is changed in the dashboard, it won't work anymore.
We could introduce another "skipSend" field, but then the messages would still be sent in older dashboards (so I would introduce a breaking change in the SVG node. Although I could again add again a checkbox "send errors to the server"...).

Any thoughts?

Hi Dave (@dceejay),
I have installed your beta version from Github.
Everything seems to be working fine (both on old version and the new version):

orig["_fromInput"] = true; // Legacy code for older dashboard versions
orig["_dontSend"] = true; 

So no need to hurry for releasing this!
And of course: Thanks again!!!!!!

Don't worry - I won't :wink:

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.