I did a bit of digging and it paid off.
(extract from code used:)
if (typeof msg.delay === "undefined")
{
const id = env.get("NR_NODE_PATH");
const ids = id.split("/");
const errr = `msg.delay not set in message going into ${ids[1]}`;
node.error(errr, msg);
msg.source = ids[1];
return;
}
Which is all well and good for THAT instance and THAT error.
So it now begs the question to me:
How do I catch errors in a subflow and pass on the error to the parent flow so the *parent flow's error message points to the subflow node.
I'm not sure how it will work with this node already managing it's own errors.
Could I just negate this part and handle all errors with the catch node in the subflow?
Would make it easier.
![]()
I've kinda done it, but the formatting is not the best and I just get a message with the dummy error message and the node's number all in one line.
How would I format it so the node number is per real error messages?
And maybe pass on the whole error message too?
(Trying ITMT)
Update:
This is a test flow I made to check.
Thoughts?
[{"id":"089874d72f82b238","type":"subflow","name":"Error handler for subflows","info":"2024 06 17\n==========\n\nBasic overview.\n`TEST node` causes an error.\n(any input)\n\n`Upsend error message` relays the\nerror message to the parent flow.\n`error.source` -> subflow with error\n`_error.source.name` -> name of node that\ncaused the error.\n`_error.message` -> the error message\n\nSuggestion:\n-----------\nThe `catch` node should only catch\nerrors from `function` nodes.\n","category":"","in":[{"x":230,"y":70,"wires":[{"id":"18bb902b0b89f912"}]}],"out":[{"x":360,"y":190,"wires":[{"id":"830e5e8780badf3b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99"},{"id":"18bb902b0b89f912","type":"function","z":"089874d72f82b238","name":"TEST node","func":"node.error(\"Error\",msg)","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":70,"wires":[[]]},{"id":"830e5e8780badf3b","type":"catch","z":"089874d72f82b238","name":"","scope":["18bb902b0b89f912"],"uncaught":false,"x":200,"y":190,"wires":[["06b515199b7eb047"]]},{"id":"06b515199b7eb047","type":"function","z":"089874d72f82b238","name":"Upsend error message","func":"const id = env.get(\"NR_NODE_PATH\");\nconst ids = id.split(\"/\");\nconst errr = `Something went wrong in subflow (See source number below).\\nopen the _error.source object (below) to get more details`;\nmsg.source = ids[1];\nnode.error(errr, msg);\n \n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":240,"wires":[[]]},{"id":"52cc9476d774b429","type":"subflow:089874d72f82b238","z":"7e987ddf260bdf0d","name":"","x":420,"y":3410,"wires":[["58bd64507cef17b7"]]},{"id":"897d573b21452c75","type":"inject","z":"7e987ddf260bdf0d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":3410,"wires":[["52cc9476d774b429"]]},{"id":"58bd64507cef17b7","type":"debug","z":"7e987ddf260bdf0d","name":"Used for testing.","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":3410,"wires":[]},{"id":"a28a91a006a4fee5","type":"catch","z":"7e987ddf260bdf0d","name":"","scope":["52cc9476d774b429"],"uncaught":false,"x":360,"y":3510,"wires":[["2257c395145111bb","ffcfe59eeec7ec81"]]},{"id":"2257c395145111bb","type":"debug","z":"7e987ddf260bdf0d","name":"Ok error message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":3450,"wires":[]},{"id":"ffcfe59eeec7ec81","type":"change","z":"7e987ddf260bdf0d","name":"","rules":[{"t":"move","p":"_error.source","pt":"msg","to":"error.source","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":3510,"wires":[["2acd17e7327bb6bc"]]},{"id":"2acd17e7327bb6bc","type":"debug","z":"7e987ddf260bdf0d","name":"Better error message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":880,"y":3510,"wires":[]}]




