SO community.
I have this small piece of code that I am not sure if it's not filled with bad practices. Basically the email message that i am trying to validate holds some data that i am interested in later on.
I wanted to ask if it's good practice to validate passed parameters in the constuctor and throw some kind of exception afterwards.
How would YOU handle this?
Thank you, Bob.
public EmailSubjectValidator(EmailConfig emailConfig, Message msg) {
this.emailConfig = emailConfig;
if (msg == null || msg.isExpunged()) {
throw new NullPointerException("Error: EmailSubjectValidator found a message that is either null or was already removed from the server. ");
}
this.msg = msg;
}