REFramework BusinessRule Exception

Hey Forum :grinning:

I’m trying to build a simple robot in REF (just the default from UiPath) for practice.

In ‘Process Transaction’ there is a try/catch with BusinessRuleException and Exception.
In the invoked Process workflow I wanna use a get text and if if cant get that text, I wanna throw a businessruleexception to the outer scope (= Process Transaction).

How would I set that up?

Thanks in advance, great forum!

If an exception occurs outside of a Try block (also known as an unhandled exception). This will cause your entire robot to “crash” and the entire process flow is terminated. There is now a global exception handler but lets not go into that. Here is some more information about that: Global Exception Handler

If an exception occurs inside of a Try block, you are able to handle it accordingly. The exception becomes a handled exception where you could apply logic to gracefully handle the error. Any exception inside a Try block is caught.

Now which Try block will catch the exception? It is whichever Try block it is currently in. It does not matter in which worklow file that is. Only one Try block will catch the exception. If you would like several to become triggered you will have to use the Rethrow activity to throw an exception again in the Catch block. This will cause an exception again causing it to go to the outer Catch block (if any).

Now to answer your question: Put a Try block around your Get Text activity and catch any exception. In the Catch block use the Throw activity to throw new BusinessRuleException("Your error message"). I would use exception.Message as exception message of your BusinessRuleException.

So what happens here?

  1. An exception occurs in your Workflow file.
  2. The exception is caught by the Try block in that very same Workflow file.
  3. In the Catch block the exception is thrown again as a BusinessRuleException.
  4. The next Catch block to catch the exception is the one outside of your Workflow file (the one within the Process state).
3 Likes

Check the “Source” of the exception message. Its referring to the Attach Browser activity.

It cannot find the selector of the window you’re trying to attach to.

3 Likes

Thanks (me being stupid)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.