I have the following situation.
I have a Java class that inherits from another base class and overrides the method. The base method does not throw exceptions and therefore does not have a throws ... declaration.
Now my own method should be able to throw an exception, but I have a choice for
- Swallow an exception
- Add throw ad
Both do not satisfy, because the first one silently ignores the exception (normal, I could do some logging), and the second generated compiler errors due to different method headers.
public class ChildClass extends BaseClass { @Override public void SomeMethod() { throw new Exception("Something went wrong"); } }
java exception-handling
Jรผrgen Steinblock Dec 23 2018-10-12 14:24
source share