I have a custom exception like this
public class MyOwnException extends Exception {
}
Then in my class
I have two methods
public void ExceptionTest() throws Exception {
throw new FileNotFoundException();
}
public void ApplicationExceptionTest() throws MyOwnException {
throw new FileNotFoundException();
}
Eclipse complains about the second method 'Unhandled exception type FileNotFoundException'. I thought since MyOwnException extends Exception it shouldnt complain...
Can anyone tell me what I am missing here?
解决方案
Extension tree
Exception
IOException
FileNotFoundException
MyOwnException
FileNotFound and MyOwn did not know each other.
public void ApplicationExceptionTest() throws Exception
{
throw new FileNotFoundException();
}
is the way to go
Comment:
I hope this is for mockup testing only and not for implementing a class you wnt to use in your regular source code!