+ 1
How can we catch all kind of exceptions in a single catch block?
4 Antworten
+ 4
by simply placing possible errors that may occur in a statement in a try statement or using multiple try statements.
+ 2
try {
// code
}
catch (...){
// code
}
+ 2
In your "Catch" have a switch with the known values and a "Default" for everything else.
Alternatively, you could use if/else if there are not many known values.
+ 1
try { } catch (Exception ex) { }
Exception is the base class from which all kinds of Exceptions are derived. So, this catch block effectively catches all kinds of Exceptions