Lombok: How to use lombok to create custom exception faster.

Created on 12 Jan 2018  路  4Comments  路  Source: projectlombok/lombok

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?

Most helpful comment

I would love for this to be a feature of Lombok. In the same way that we have annotations to create constructors based on properties, it would be nice to have an annotation that creates the usual constructors for Exceptions.

All 4 comments

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.

I would love for this to be a feature of Lombok. In the same way that we have annotations to create constructors based on properties, it would be nice to have an annotation that creates the usual constructors for Exceptions.

@Exception annotation would be so helpful

See also #375 and https://groups.google.com/forum/#!topic/project-lombok/x1DdJvG-PKc

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lombokissues picture lombokissues  路  42Comments

kevcodez picture kevcodez  路  58Comments

pgaschuetz picture pgaschuetz  路  42Comments

lex-em picture lex-em  路  61Comments

eximius313 picture eximius313  路  45Comments