I'm developping a Swing application, with a form on which I process several validations using exceptions. Knowing that since Java 7 it is possible to use a mutli-catch statement, I used it to improve my code, but since then the Stacktrace always begins with :
"java.lang.Exeption :" + Handling Exception Message.
How I could remove "java.lang.Exeption :" of this message ?
Here is an example from some of my validations and execution.
ActionEvent:
public void actionPerformed(ActionEvent arg0){
//Validation 1
NomeGrupoVazio(string1);
//Validation 2
ValidaString(string2);
//Validation 3
DiferenciarRMs(int1, int2, int3, int4);
}
Valitadions:
private void NomeGrupoVazio(String nome) {
if (nome.isEmpty()) {
throw new IllegalArgumentException("Preencha o nome do grupo!");
}
}
private void ValidaString(String s) {
Pattern pattern = Pattern.compile("[0-9]");
Matcher matcher = pattern.matcher(s);
if (matcher.find()) {
throw new IllegalArgumentException(
"Por favor digite apenas caracteres não numéricos nos campos referentes aos nomes");
}
}
private void DiferenciarRMs(int rm1, int rm2, int rm3, int rm4) {
if (rm4 == 0) {
if (rm1 == rm2 || rm1 == rm2 || rm1 == rm3 || rm2 == rm3) {
throw new IllegalArgumentException(
"Todos os RM's precisam ser diferentes");
}
} else if (rm1 == rm2 || rm1 == rm3 || rm1 == rm4 || rm2 == rm3
|| rm2 == rm4 || rm3 == rm4) {
throw new IllegalArgumentException(
"Todos os RM's precisam ser diferentes");
}
Thanks in advance!