How To Pick Out Handgrip Of A Constraintviolationexception Inwards Javaee

The next slice of code grab a ConstraintValidationException inwards JavaEE then that nosotros volition travel able to display an appropriate message to the user instead of a long stack trace.


try {     //perform a transaction functioning here, mayhap a delete } grab (EJBTransactionRolledbackException e) {     Throwable t = e.getCause();     piece ((t != null) && !(t instanceof ConstraintViolationException)) {         t = t.getCause();     }     if (t instanceof ConstraintViolationException) {} } 

As you lot tin run into nosotros grab EJBTransactionRolledbackException, why  not ConstraintViolationException? Trust me it volition non travel because that exception is already wrapped past times the container, then to travel able to procedure it nosotros ask to disclose it again.
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.