# Help with error detection creation

**URL:** https://discourse.nodered.org/t/help-with-error-detection-creation/37950
**Category:** General
**Created:** [23 December 2020 22:15 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950 "2020-12-23T22:15:19Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [23 December 2020 22:15 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950/1 "2020-12-23T22:15:19Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [23 December 2020 23:06 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950/2 "2020-12-23T23:06:56Z")

</div>

> [@Trying\_to\_learn](#):
>
> 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...

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

```

For node.warn, I do this...

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

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [24 December 2020 01:15 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950/3 "2020-12-24T01:15:44Z")

</div>

> [@Steve-Mcl](#):
>
> For the error, you could add them to msg e.g...

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 December 2020 09:59 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950/4 "2020-12-24T09:59:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [24 December 2020 10:01 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950/5 "2020-12-24T10:01:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 February 2021 10:01 UTC](https://discourse.nodered.org/t/help-with-error-detection-creation/37950/6 "2021-02-22T10:01:42Z")

</div>

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