How to pass an error from a subflow to a main flow

JuFe
Kilo Expert

I am searching for a method to stop a main flow from further exections in case a subflow arrives at a certain step. I don't really want to create the overhead of returning a status code and checking it via if statement in the main flow.

Is there any way to end a subflow in a way that will trigger error handling in the main flow?

1 ACCEPTED SOLUTION

JuFe
Kilo Expert

I've now solved this by creating a custom action which thorws and error message I put into it. This will then be caught in the subflow error handler to do further actions. After these actions I can use the custom action again in the error handler to trigger the main flow's error handler.

Subflow

  • [do stuff]
  • Custom Action [Throw Error]

Subflow Error Handler

    • [do stuff]
    • Custom Action [Throw Error]

Main flow Error Handler (gets triggered by subflow error)

      • [do stuff]

View solution in original post

3 REPLIES 3

Jan Strama1
Tera Guru

Hi JuFe,

 

If I get you right, you want to handle an Error when a Subflow you called from the Mainflow. Is this correct?

If yes, it is pretty easy, as the Error in the Subflow would be caught as error in the Main Flow so you can handle it there. 

Here an example from one of my failing Subflows:
find_real_file.png

 

 

If you want to do something else, I do not see any other easy way besides setting a Subflow Output which you then parse in your main Flow.

Otherwise you would need to lookup the running instance of your main flow from within the Subflow and cancle/error it, which is way more complex than actually just handling the Output Variable.

 

Hope this was helpfull

suvro
Mega Sage
Mega Sage

Best option available is to use the return activity to pass the error in main flow and handle it from there

JuFe
Kilo Expert

I've now solved this by creating a custom action which thorws and error message I put into it. This will then be caught in the subflow error handler to do further actions. After these actions I can use the custom action again in the error handler to trigger the main flow's error handler.

Subflow

  • [do stuff]
  • Custom Action [Throw Error]

Subflow Error Handler

    • [do stuff]
    • Custom Action [Throw Error]

Main flow Error Handler (gets triggered by subflow error)

      • [do stuff]