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: https://docs.uipath.com/studio/docs/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?
- An exception occurs in your Workflow file.
- The exception is caught by the Try block in that very same Workflow file.
- In the Catch block the exception is thrown again as a BusinessRuleException.
- The next Catch block to catch the exception is the one outside of your Workflow file (the one within the Process state).