Uipath Certified RPA Associate Uirpa · Free Practice Question Medium
Question 19
Scenario: You created multiple exception types in the Catch block and an exception has occurred which fits more than one type.
Which block will execute?
-
A
The first match defined
-
B
The block with most generic match
-
C
The block with most specific match
-
D
All matching blocks in the order they are defined
Reveal correct answer
Correct answer: C
Explanation
When multiple rules have been put into place to catch and manage errors, the block with the most specific match will be applied.
https://forum.uipath.com/t/how-to-use-multiple-business-rule-exception/244032/2
Since C# 6 we have Exception Filters that allow us to ‘filter’ our catch-blocks. If we want to handle multiple types of exceptions in the same way using Exception Filters, we could write this:
- try
- {
- DoSomethingThatCanGoWrong(myVar);
- }
- catch(Exception ex) when(ex is ArgumentException || ex is FileLoadException)
- {
- HandleException(ex);
- }
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
