When I define a new exeption on IntelliJ IDEA Ultimate and use ctlr + enter to create the exception class, it extends Throwable by default, I would like to change that to exception but I can't find where it is in the settings.
I've tried to to the settings in Editor -> File and Code Templates but I can't find what I'm searching for.
Overriding default behavior for creating new exception classes in not available yet for IntelliJ IDEA. Here is a feature request.
Still it is possible to use LiveTemplates.
For example, to make the created exception class extend the Exception class instead of Throwable modify the code as follows:
public class $NAME$ extends Exception {
public $NAME$() {
}
public $NAME$(String message) {
super(message);
}
public $NAME$(String message, Throwable cause) {
super(message, cause);
}
public $NAME$(Throwable cause) {
super(cause);
}
protected $NAME$(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
After making the desired changes, click Apply
button to save changes.
Usage:
Tab
key.