So I was sending code for review and approvals for some changes I made recently. that includes a class as below:
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UnKnownClientException extends CustomException {
public UnKnownClientException (String message, Throwable throwable) {
super(message, throwable);
}
}
@Setter
@Getter
public abstract class CustomException extends ContextedRuntimeException {
private ApiException apiException;
public CustomException (String message, Throwable throwable) {
super(message, throwable);
}
}
so there was a debate with my colleague as to use @Data vs @Getter, @Setter.
I was reasoning that as we are not using any other @Data shortcuts except, @Getter, @Setter, I added @Getter, @Setter but my colleague argues that it is safe to use @Data as a good practice. But I think as we have a custom constructor even with @Data we have to add that code manually. So not sure which side is correct. Looking for more insights..
UnKnownClientException
that you've posted doesn't need any Lombok. Arguably, exceptions should be@Getter
only to prevent their fields from changing as the stack unwinds.