We all know that using Exception Handling to control your program's logical flow is bad. That is, you would never do:
public void someMethod(Object someObject) {
try {
someObject.doSomething();
} catch (NullPointerException npe) {
//handle Null case
}
}
over
public void someMethod(Object someObject) {
if(someObject != null) {
someObject.doSomething();
}
}
My question is, what are some good exceptions (har!) to this rule? In Java, I can think of using MalformedURLException
to determine if a String is a URL or not. What other cool abuses of exception handling have you seen?