Subflows - question about names

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.

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.

1 Like

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.

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.

[{"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":[]}]

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