I need to create some custom exception which extends RuntimeException like:
@NoArgsConstructor
public class DuplicateException extends RuntimeException {
private static final long serialVersionUID = 2610477518423283258L;
public DuplicateException(String message) {
super(message);
public DuplicateException(String message, Throwable cause) {
super(message, cause);
public DuplicateException(Throwable cause) {
super(cause);
They are basically the same, but some is subclass of this.
How to create them faster using lombok?
Use a template. For instance on netbeans you have templates for classes, interfaces and so on, you can copy one and give it the shape of your choice.
I have the same needs as you do and creating exceptions from three clicks and typing the name cannot be beaten by any annotation.