Exception hierarchy

Hello, everyone,

what does the exception hierarchy look like in UiPath?

System.exception
Business.exception

Do I understand it correctly, if I would say that the System.Exception contains all exceptions, also the Business.Exception and others?

Is there a tree or something similar?

A BusinessRuleException is a subset of all exceptions. UiPath sends errors in the Catch portion of the Try/Catch to whichever is most specific and applies to the error thrown. Therefore, only businessruleexception exceptions will reach the BusinessRuleException part of the catch block, and all others would go to the Exception part of the catch block.

Suppose I have two TryCatch activities in each other.

In the inner TryCatch activity I catch only one Application.Exception in the Catch part and throw it with the Throw activity.

In the outer TryCatch I catch only one Bussines.Exception in the Catch part.

Would the Application.Exception not be considered here?

Not sure in this case. It depends on whether your try/catch for the business exception is in the catch block or the try block. It sounds like it would be better to have two separate catch blocks in a single try/catch block, however.

I know this is strange but Business Exception is the children of System exception. If you have a try and catch with a system.exception and businessRuleException and a business exception is occurring, the body of Business Rule Exception will be executed (the children).

Hello,

I would say that BRE will not be catch if you’re expecting ApplicationException but will be catch as Exception, ApplicationException will not be catched as BRE but will be catch as Exception too.

GetType(ApplicationException).IsAssignableFrom(GetType(BusinessRuleException)).ToString
False

GetType(BusinessRuleException).IsAssignableFrom(GetType(ApplicationException)).ToString
False

GetType(Exception).IsAssignableFrom(GetType(ApplicationException)).ToString
True

GetType(Exception).IsAssignableFrom(GetType(BusinessRuleException)).ToString
True

1 Like

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