I'm trying to create an error handler workflow and noticed an odd behavior I cannot understand. In the following example I'm simplifying my workflow as much as possible to reproduce my issue.
I'll show 2 workflows. The first one, called buggy, is the main workflow throwing an error:
I use the Default error handler with a workflow called handle error to react on errors.
Here is how handle error looks like:
This flow is also throwing an error, and I try to handle it with another Default error handler. But this is not working, if I run buggy, I end up in an infinite loop:
[2019-04-06 22:33:12.314] [E] Error in (Workflow:buggy / Throw error (item1)#0) bug1
[2019-04-06 22:33:12.375] [I] Don't worry, I'll take care of bug1
[2019-04-06 22:33:12.392] [E] Error in (Workflow:handle error / Oops (item2)#0) Oops
[2019-04-06 22:33:12.429] [I] Don't worry, I'll take care of Oops
[2019-04-06 22:33:12.444] [E] Error in (Workflow:handle error / Oops (item2)#0) Oops
[2019-04-06 22:33:12.482] [I] Don't worry, I'll take care of Oops
[2019-04-06 22:33:12.501] [E] Error in (Workflow:handle error / Oops (item2)#0) Oops
[2019-04-06 22:33:12.547] [I] Don't worry, I'll take care of Oops
[2019-04-06 22:33:12.564] [E] Error in (Workflow:handle error / Oops (item2)#0) Oops
[2019-04-06 22:33:12.598] [I] Don't worry, I'll take care of Oops
This was the only way to make handle error work:
And the resulting (desired) logs:
[2019-04-06 22:53:55.027] [E] Error in (Workflow:buggy / Throw error (item1)#0) bug1
[2019-04-06 22:53:55.076] [I] Don't worry, I'll take care of bug1
[2019-04-06 22:53:55.125] [I] Ignoring Oops
So the goal is catch errors in the handle error flow itself. My real handle error flow is much more complex and I did not like this workaround of setting the error path of each step. I prefer a nested Default error handler but I could not make it behave.
Any ideas?
In your default error handler you need to have an error path for that script. Since you don't it loops back to the default. Anytime I use a default error handler I make sure all scripts, actions, workflows, etc that get called all have an error path that goes to an end to avoid that.
Is this the correct one? I wonder why can't I substitute the error paths with another Default error handler here.
This is another solution that prevents infinite loop in buggy workflow, but needs extra care of using handle error and I want to avoid that:
Which one do you recommend?
I guess its mostly personal preference. Whatever works... I keep my error swim lane off on its own and don't ever loop back in any way.