say I have the following
try{
//something
}catch(Exception generic){
//catch all
}catch(SpecificException se){
//catch specific exception only
}
The catch blocks are tried in order, and the first one that matches the type of the exception is executed. Since Exception
is the superclass of all exception types, it will always be executed in this instance and the specific cases will never be executed. In fact the compiler is smart enough to notice this and raise a compilation error.
Just reorder the catch clauses.