I am curious about if I should add throws ExceptionClass
or not after the method's signature.(ExceptionClass extends RuntimeException)
For instance:
public void foo() // throws ExceptionClass
{
// ...
throw new ExceptionClass("");
}
If you use the JDK as a guidance, RuntimeException are not in the methods signature but are documented in the javadoc. You can have a look at collections for example.
Ideally you don't need to add runtime exception in method's throws clause. Since you want the consumer of this method to be aware of chances that this method may throw exception , i would say use javadoc either. Below is example of how you should use :
/**
*
* @throws ExceptionClass
*/
public void foo()
{
// ...
throw new ExceptionClass("");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With