Get argument from an process with exception in REFramework



The invoked process I run have an out argument, and the argument is set in the beginning of the process/xaml.
But if the process then have an Exception, with Throw: new Exception("…"), it seems like the argument doesn’t get sent back to the original invoker.

So, does out arguments not get “saved” to the invoking process if there’s an exception?
When there’s an Exception the Framwork will continue to SetTransactionStatus->HandleSystemError, and even though I send my variable here it is empty. (I need the variable to be included in an e-mail that is sent if there is an error).




I am sorry, but it is not that clear to me. Is it possible to get the argument value in the calling XAML after throwing an exception?

If yes, would you mind giving me an example? I am not bal eto do so. The argument is going back to the “caller” XAML, but if it goes back because of the THROW, it is empty, even when it has a value.

I am so sorry if this is no tthe right place, but I am new and I dont have it that clear.





Did you get solution for this?


Hi @snoopy @Pratiksha @Eric_Dimitri

I got it! I needed to extract a string as an out argument from the workflow deep in my ProcessTransaction.xaml.

The idea is to pass your variable as a log field of the exception :slight_smile:


  1. Wrap your workflow that is supposed to out your argument in Try Catch
  2. Catch your exception and add your log field:


3. Now you can assign your log field to a variable whenever the exception is handled higher in higher workflows:

I used it as an alternative to writing the variable to a temporary text file.

@ClaytonM I saw your answer on similar topic in one of the older threads. Would you maybe have a moment to gauge whether there are potential flaws to this solution (I would like to know if it is robust).


Nice solution, will try it out on next project. :slight_smile:
I also used a temp txt.


Yeah @loginerror
There are various ways to capture the exception, and yours looks good. Just make sure you are capturing the .Source if it isn’t already because that will tell you the activity that failed (note: always rename your activities to something unique)

To the thread title specifically, getting an argument back from a workflow that failed is only possible if you surround the workflow with the Try/Catch, store the exception to another argument, and ensure that no exception is thrown. When the exception is thrown, all arguments are not returned. loginerror presented a good way to do this, however using the Rethrow will throw the exception so the arguments won’t be returned, from my understanding (I could be wrong).

Now typically, you want to do exception capture in the framework so you are not coding in repetitive actions and performing the same exception actions on all portions of the process. But, in the case where you want the argument to be returned, you would want the workflow to not throw an exception, which means you need to surround it by a Try/Catch, capture the exception either with assign and/or log message. Then, the arguments will return to the framework, and you would use the Throw activity with the stored exception in the framework in order to show an error occurred.

I don’t usually surround the workflows with a Try/Catch though (I did earlier in my UiPath adventure), because my goal is for the framework to handle all exceptions.

I hope this bit of information is helpful :laughing:

In summary, to return the arguments you will do something like this:

---REFramework, Try/Catch around Process Flowchart, Invoke Workflows
---Surround workflows that you need to return arguments with a Try/Catch
------In Catch, store exception to either an exception type variable or to a string including the exception.Source and .Message... don't Rethrow error here

---After Invoke in REFramework, check if there was an exception, and throw exception
------In catch, do all exception actions like Log Message somewhere, take screenshot, et cetera

Regards. @snoopy



Awesome read. Yes, the rethrow is there only for framework to handle saving my logged variable to the file higher in the process. The argument value is not out, but the value I want is now traveling as a log field of the exception that is rethrown to be used when framework will handle it a few steps higher :slight_smile: