When I write a new exception type, am I supposed to write only the constructors needed, or implement all constructors exisiting in Throwable (and calling them by super())?
When thinking about it, I would say implement only what is needed (YAGNI – You Ain’t Gonna Need It). If I need another constructor later, I just add it.
Example:
public void MyException extends RuntimeException {
// I only need this constructor
public MyException(Throwable cause) {
super(cause);
}
}
Only implement what you’ll need and add as you need them. I usually add the one with the String message and the one you have (for wrapping another Exception).