# Subflow error source is not searchable

**URL:** <https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481>\
**Category:** Core Development\
**Created:** [8 August 2021 12:18 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481 "2021-08-08T12:18:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 August 2021 12:18 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481/1 "2021-08-08T12:18:31Z")

</div>

A subflow containing a function node throws an error.  
The error is caught by a catch node in the flow where the subflow instance is placed.

The catch node shows the `msg.error.source.id`. However, we can;t search the `id` in the flow. I would believe that id belongs to the function node inside the instance of the subflow.

Issue: The problem with this is that when multiple subflow instances exist, it is impossible to find the source of error.

Possible resolution: The msg.error.source.id should show the value of the subflow isntance node id.

---

<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:** [8 August 2021 12:39 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481/2 "2021-08-08T12:39:12Z")

</div>

You can feed the catch node to an output on the subflow and then you can identify which subflow instance it is.

---

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 August 2021 12:41 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481/3 "2021-08-08T12:41:17Z")

</div>

You mean I should catch the error inside the subflow? that doesnt make sense.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 August 2021 13:35 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481/4 "2021-08-08T13:35:05Z")

</div>

Here is a sample of how you could identify the subflow. Add a change node before calling the subflow and set msg.subflow with an id. In the subflow have a `catch` node output to what ever you want and you can look at msg.subflow to identify the one with the error.

```auto
[{"id":"92c501212dc80de3","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ac694b799e60a6eb","type":"subflow","name":"Subflow 1","info":"","in":[{"x":182,"y":109,"wires":[{"id":"fcff780a52f6493d"}]}],"out":[{"x":533,"y":101,"wires":[{"id":"fcff780a52f6493d","port":0}]},{"x":538,"y":172,"wires":[{"id":"637894b7751611bf","port":0}]}]},{"id":"d16b9fac.8212a","type":"debug","z":"92c501212dc80de3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":781,"y":132,"wires":[]},{"id":"c5ee9670.5dbbd8","type":"inject","z":"92c501212dc80de3","name":"Trigger error","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test 1","payloadType":"str","x":147,"y":101,"wires":[["cc86c223f2cca699"]]},{"id":"637894b7751611bf","type":"catch","z":"ac694b799e60a6eb","name":"","scope":["fcff780a52f6493d"],"uncaught":false,"x":347,"y":167,"wires":[[]]},{"id":"fcff780a52f6493d","type":"function","z":"ac694b799e60a6eb","name":"Throw Error","func":"node.error(\"an example error\", msg); ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":355,"y":97,"wires":[[]]},{"id":"dfb1a38fcfd261ec","type":"subflow:ac694b799e60a6eb","z":"92c501212dc80de3","name":"","x":521.5,"y":103,"wires":[["e941c954973d581b"],["d16b9fac.8212a"]]},{"id":"e941c954973d581b","type":"debug","z":"92c501212dc80de3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"error","targetType":"msg","x":796,"y":84,"wires":[]},{"id":"fd098cbc70720b21","type":"subflow:ac694b799e60a6eb","z":"92c501212dc80de3","name":"","env":[],"x":524.5,"y":237,"wires":[["dc78e17c9897392a"],["85425cc166c4ba62"]]},{"id":"98ec8d620681232f","type":"inject","z":"92c501212dc80de3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":138.5,"y":238,"wires":[["c3c5cc98a3ab746b"]]},{"id":"dc78e17c9897392a","type":"debug","z":"92c501212dc80de3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":777.5,"y":209,"wires":[]},{"id":"85425cc166c4ba62","type":"debug","z":"92c501212dc80de3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":772,"y":253,"wires":[]},{"id":"cc86c223f2cca699","type":"change","z":"92c501212dc80de3","name":"","rules":[{"t":"set","p":"subflow","pt":"msg","to":"copy 1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340.5,"y":103,"wires":[["dfb1a38fcfd261ec"]]},{"id":"c3c5cc98a3ab746b","type":"change","z":"92c501212dc80de3","name":"","rules":[{"t":"set","p":"subflow","pt":"msg","to":"copy 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":333,"y":238,"wires":[["fd098cbc70720b21"]]}]

```

 ![Screen Shot 2021-08-08 at 9.34.07 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/c/0c189d4556ac6ad54b2ddc558203f2d4e1df5cae.png)

 ![Screen Shot 2021-08-08 at 9.34.28 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e1a2939d95d3cfbb93daff1e8e86fe3a6f8035a.png)

---

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 August 2021 23:48 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481/5 "2021-08-08T23:48:06Z")

</div>

Thanks for your example. It is a valid workaround.  
But am looking to see how we can resolve this as part of the core development of NR

---

<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:** [7 October 2021 23:48 UTC](https://discourse.nodered.org/t/subflow-error-source-is-not-searchable/49481/6 "2021-10-07T23:48:47Z")

</div>

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