The Java interface doesn't declare any exception. How to manage checked exception of the implementat
Posted
by Frór
on Stack Overflow
See other posts from Stack Overflow
or by Frór
Published on 2010-04-29T16:02:39Z
Indexed on
2010/04/29
16:07 UTC
Read the original article
Hit count: 237
Let's say I have the following Java interface that I may not modify:
public interface MyInterface {
public void doSomething();
}
And now the class implementing it is like this:
class MyImplementation implements MyInterface {
public void doSomething() {
try {
// read file
} catch (IOException e) {
// what to do?
}
}
}
I can't recover from not reading the file.
A subclass of RuntimeException
can clearly help me, but I'm not sure if it's the right thing to do: the problem is that that exception would then not be documented in the class and a user of the class would possibly get that exception an know nothing about solving this.
What can I do?
© Stack Overflow or respective owner