# Subflows - question about names

**URL:** <https://discourse.nodered.org/t/subflows-question-about-names/47609>\
**Category:** General\
**Created:** [24 June 2021 22:00 UTC](https://discourse.nodered.org/t/subflows-question-about-names/47609 "2021-06-24T22:00:33Z")\
**Posts on this page:** 5\
**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:** [24 June 2021 22:00 UTC](https://discourse.nodered.org/t/subflows-question-about-names/47609/1 "2021-06-24T22:00:33Z")

</div>

Ok, I write a `subflow`.

For the sake of being nice I add a `catch` node to catch any errors and send that to an output so I can use it _in the real world_.

But I seem to be missing the _trick_ where I can name the subflow.

(To digress quickly)

I write a `function` node and put my code in it.  
I name the node and if/when I get an error I am told the name of the node and am pointed to it.

That is nice.

Subflows (alas - and I understand why) can't do this.  
That is because they can be used in several places in the flow.

So I am asking this:  
Instance one of subflow use I name the _node_ `one` (yeah... indulge me) and the second time I call it `two`.

Is there a way in the subflow I can get the name of the _node_ and pass it out with the error?  
That way when I look at the error I know if it is _one_ or _two_ who got the error.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 June 2021 22:19 UTC](https://discourse.nodered.org/t/subflows-question-about-names/47609/2 "2021-06-24T22:19:56Z")

</div>

It is not (currently) possible for a flow inside a subflow to access the name of the subflow instance.

A workaround is to define a custom property on the subflow which _can_ be accessed by the nodes inside the subflow. This is because subflow properties appear as environment variables to the nodes inside it.

Can't easily create a demo for you until the morning, but hopefully that gives to you a bit of a steer.

---

<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 June 2021 22:21 UTC](https://discourse.nodered.org/t/subflows-question-about-names/47609/3 "2021-06-24T22:21:43Z")

</div>

Thanks.

Ok, I shall have to look into that. I've never played with those things, but I guess this is a good time for me to try.

Again: Appreciated and yes: thanks for the pointer.

---

<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 June 2021 23:05 UTC](https://discourse.nodered.org/t/subflows-question-about-names/47609/4 "2021-06-24T23:05:11Z")

</div>

Only to not flood the forum with too many topics.

Taking on what Nic told me, I have made this test flow.

It isn't too complicated.

Pressing either `timestamp` node the message goes through. _Dummy_ message.  
Pressing either `error` node makes the subflow throw an error - or so I hope.

But ..... although it does, I am not understanding why the `catch` node isn't seeing it.  
All I get are messages (see picture) which are ok, but the question remains: why isn't the `catch` node _catching_ the errors?

I hope the screen shot helps you understand.

There is nothing shown in the `Error` debug node's output.

The _names_ in the error messages are set in the `subflow` environment variable tab.

```auto
[{"id":"6093ac68.4d618c","type":"subflow","name":"Subflow 1","info":"","in":[{"x":180,"y":200,"wires":[{"id":"e32780f4.c61eb"}]}],"out":[{"x":490,"y":200,"wires":[{"id":"e32780f4.c61eb","port":0}]}]},{"id":"e32780f4.c61eb","type":"function","z":"6093ac68.4d618c","name":"","func":"var name = env.get(\"name\");\n\nif (msg.payload == \"error\")\n{\n node.error(name);\n return null;\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":200,"wires":[[]]},{"id":"bf601604.73ebf8","type":"subflow:6093ac68.4d618c","z":"88de1ac2.8b8c38","name":"one","env":[{"name":"name","value":"one","type":"str"}],"x":380,"y":1390,"wires":[["984aaa45.8d36"]]},{"id":"3cb871d3.9af3be","type":"inject","z":"88de1ac2.8b8c38","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":1390,"wires":[["bf601604.73ebf8"]]},{"id":"984aaa45.8d36","type":"debug","z":"88de1ac2.8b8c38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":1390,"wires":[]},{"id":"2f3bd436.8abd04","type":"subflow:6093ac68.4d618c","z":"88de1ac2.8b8c38","name":"two","env":[{"name":"name","value":"two","type":"str"}],"x":380,"y":1500,"wires":[["c76ebc4d.4419e8"]]},{"id":"efd8925d.383ed8","type":"inject","z":"88de1ac2.8b8c38","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":1500,"wires":[["2f3bd436.8abd04"]]},{"id":"c76ebc4d.4419e8","type":"debug","z":"88de1ac2.8b8c38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":1500,"wires":[]},{"id":"a4ced8ae.a3189","type":"inject","z":"88de1ac2.8b8c38","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"error","payloadType":"str","x":210,"y":1360,"wires":[["bf601604.73ebf8"]]},{"id":"6b97b36e.4f92c4","type":"inject","z":"88de1ac2.8b8c38","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"error","payloadType":"str","x":210,"y":1470,"wires":[["2f3bd436.8abd04"]]},{"id":"de6f1e4b.a26be","type":"catch","z":"88de1ac2.8b8c38","name":"","scope":null,"uncaught":false,"x":390,"y":1600,"wires":[["9c9c3c31.a55628"]]},{"id":"9c9c3c31.a55628","type":"debug","z":"88de1ac2.8b8c38","name":"Error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":1600,"wires":[]}]

```

 ![Screenshot from 2021-06-25 09-02-10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a62ea421913380491bdf94a43932b9557b661cc6.png)

---

<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:** [23 August 2021 23:06 UTC](https://discourse.nodered.org/t/subflows-question-about-names/47609/5 "2021-08-23T23:06:08Z")

</div>

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