I am trying to ensure arguments get passed from child workflow to parent workflow even when an exception is thrown in the child workflow. I am catching the exception in the child workflow and then rethrowing. However, rethrowing causes my arguments to NOT get passed up to parent. Any ideas on how to still pass arguments to parent?
I’m no expert, but I think a bespoke solution might help here.
- You make use of a variable to indicate whether your child process executed successfully or failed with some exception.
- Instead of rethrowing the exception, you update the variable and pass it back as norm.
- You can check the value of this variable in your parent workflow to take the necessary action.
This will allow you to always have access to the other arguments irrespective of the data state.
Hope this helps.
The issue with that solution is I need to be able to exit my child workflow in the event an exception occurs within it. In other words, if an exception happens in the child workflow, I don’t want to continue doing activities. I want to go back to the parent immediately. That is the reason why I rethrow. So I have doubts about your suggestion of not rethrowing the error. Hope that makes sense.
True, I missed that.
In that case, you can check the usage of the Terminate workflow activity and see if you achieve the desired result.
Make sure if you don’t have one more try-catch above that throw…
It should work…and go back to parent flow…
if you want to pass your arguments back to parent even when exception is thrown, then you shouldnt rethrow.
Maybe you can add one more output argument in the child workflow called “out_exception”, if the child workflow has exception, then in the “catch” statement, set out_exception = exception.message, otherwise set out_exception = “”, and dont rethrow
Then in the main workflow check if out_Exception=blank or not . If its not blank then you know theres an exceptionn in child workflow
But what if I need to exit the chid workflow immediately upon incurring an error. Then what?
I’m running into the same issue.
You could try catching the exception, then concatenating your argument variables onto your exception message. Then in the parent workflow parse your arguments back out from that message.
For example if your exception.Message = “Improper value” then use an assign that sets exception.Message = “Improper value; Arg1=James, Arg2=12345” within the Catch. Then in your parent workflow use exception.Message.Split(“;”) to recover your arguments.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.