Stuck simulating errors. (try 2)

I have had a few problems recently and it is the routine that has bitten me on the b*m.

And typically it is the error routine which is at fault.

To try and catch the error, and find the problem I separated the two parts and now want to inject a control signal to simulate the error.

(Actually)
Skip to bottom it may be more important.

This is a test error message I want to inject:

{"message":"ReferenceError: a is not defined (line 1, col 19)","source":{"id":"c552872d.7f144","type":"function","name":"This will throw an error","count":1}}

Cut from the debug node.

I am trying to set up a function node to inject it but I can't get it working.

I know it is stupid me not understanding how to do it, but . . . . .

When I put it in an inject node then pass it to a function node, I generate infinite errors.
(If it is actually in the flow)

Could someone help me find the elephant?

[{"id":"39bbd9ef.ce813e","type":"function","z":"accbdb61.d75918","name":"","func":"msg = {\"message\":\"ReferenceError: a is not defined (line 1, col 19)\",\"source\":{\"id\":\"c552872d.7f144\",\"type\":\"function\",\"name\":\"This will throw an error\",\"count\":1}}\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":230,"wires":[[]]},{"id":"96ab98ce.848a8","type":"inject","z":"accbdb61.d75918","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":230,"wires":[["39bbd9ef.ce813e"]]}]

All that aside:
The underlying problem is that I am trying to catch errors.
When I do, usually (maybe originally) it worked.

By doing something innocent I have messed things up.

I can't catch the errors now because when I catch them, that in itself causes an error.

Thus: run away errors.

How can I catch the errors if doing that generates errors itself?

I can post that part of the flow if you want.

Just speaking out of top of my head but I wouldn't have thought you could simulate the error you are seeing in your debug node.

(unless someone has told you differently of course)

Errr...... I think I can.

For the sake of it this is the code I used:

var n = 23 + 56 / a;
//var n = 23 + 56 ;
msg.payload = n;
return msg;

But that is just to create a generic error.

Really if a real error happens, it could be anything.

So I am not sure this is really . . . . .important other than I need it to test the flow.

So I created that error but as is it locks up the machine.

I finally found the problem. Kinda.

So I cut the flow apart.

I want to inject that error to see what is happening to cause the error feed-back loop.

So I need to inject it correctly.

But when I put that in a function node, that in itself errors. Which shouldn't. It is just a message.

So I'm missing something.

(ARGH!)

Found it!

From the other night - thread.

What didn't help was that I lost a couple of backups and used an older version.

Though while I was updating, I thought I was smart and archived a part of the flow.

I imported that while updating and only after the past hour of chasing my tail, I realised the problem.

Sorry folks.