Precedence of Exception types?

Hi All

If in the Catch section I am using first the Exception and then SelectorNotFoundException then if any application is not found then which exception type will be caught and why ?

Hi , the exception will be considered based on which is more specific and not based on the order in catch block. So irrespective of the order if selector not found exception occurs it goes the respective block if not it goes to general exception block

1 Like

HI @kkpatel

I catch if you use System.Exception it will run for any kind of exception

and if you add another specific catch exception it will look for for most matchable exception.

if the exception not matched it will excecute the System.Exception

Generally saying its something like a switch and System.exception is like default case and others are like actual cases


1 Like

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