In Java (or any other language with checked exceptions), when creating your own exception class, how do you decide whether it should be checked or unchecked?
My instinct is to say that a checked exception would be called for in cases where the caller might be able to recover in some productive way, where as an unchecked exception would ...
I have this factory method in java:
public static Properties getConfigFactory() throws ClassNotFoundException, IOException {
if (config == null) {
InputStream in = Class.forName(PACKAGE_NAME).getResourceAsStream(CONFIG_PROP);
config = new Properties();
config.load(in);
}
return config;
}
And I want ...
I was told that in Java, unchecked exceptions can be caught in a try block, but if it's caught, isn't it called a checked exception?
...
Possible Duplicate:
When to choose checked and unchecked exceptions
Hello!
So, I'm still getting comfortable regarding when to throw a checked or unchecked exception. I would like to know what others think is the most appropriate in this case:
class Correlation<T>
{
private final T object1, object2;
private final doub...
Why does it make sense to have Runtime Exceptions UnChecked (as opposed to if they were Checked)?
...
In .NET, method signatures don't tell me if I have missed handling some exceptions that could be thrown by my code.
Is there some tool that can warn me, if say I am using a HashTable remove but haven't handled the ArgumentNullException? I don't want to be surprised at run time.
And does this mean that you need to know your code very wel...
I have an Exception chain in which method1 throws an Exception to method2 which throws the Exception on to main. For some reason, the compiler forces me to deal with the error in method2 and marks it as an error if I don't, indicating that it's a checked Exception. But when the same Exception is thrown further down the line to main, the ...
I have a method like...
int f() {
try {
int i = process();
return i;
} catch(Exception ex) {
ThrowSpecificFault(ex);
}
}
This produces a compiler error, "not all code paths return a value". But in my case ThrowSpecificFault() will always throw (the appropriate) exception. So I am forced to a put a return value at t...