Help with error detection creation

I have a subflow and in there is this bit of code:

if (ICDID != device)
{
    node.warn("Node Configuration not set");
    node.error("Node Configuration not set", msg)
    //  fa-eye-slash
    return;
}

Which is nice but I now realise I need more information.

It would be nice to know those two things too: ICDID and device.

Short of sticking them on the end of the node.error line: is there another way so I can sort of structure the message?
Then I can see them as discreet parts and not just appended to the message.

For the error, you could add them to msg e.g...

if (ICDID != device)
{
    msg.ICDID = ICDID;
    msg.device = device;
    node.error("Node Configuration not set", msg)
    return;
}

For node.warn, I do this...

if (ICDID != device)
{
    node.warn({ "message": "Node Configuration not set", ICDID: ICDID, device: device });
    return;
}

Yes, I think that was what I was saying. (I hope I was)

But that makes it a bit..... yucky with how it is seen.

I was wanting to ... make msg.ICDID and the context device part of a structure so they could be easily seen.

node.warn isn't too good as that would mean opening the edit screen and looking at the nodes.

I have code which shows me the messages (in the edit screen) at a centralised place and it would be nice if I could get it in an easier way to read.

For subflows I often have a separate debug or error output on the subflow that I send messages containing this sort of information.
Also remember you can trigger an error from a function node and catch that in a Catch node.

1 Like

I like the first part.

catch nodes may be a bit problematic for what I am doing.

But I'll have a dig around the separate output idea.