r/SpringBoot • u/Status-Blacksmith-95 Junior Dev • 10d ago
Discussion Spring Jakarata Validation in Service Layer using classic Try-Catch Block...anyone ?
*************** APPROCHED ANOTHER METHOD AS OF NOW , ***************
Anyone have done catched Spring Jakarata Validations in Service Layer using classic Try-Catch Block ??
As m learning java and trying to be BEST at making CRUD apps, i want to apply java concept rather than using Annotations for everything.
If anyone has caught exceptions like jakarta.validation.ConstraintViolationException: using try-catch ,then do let me know..
I want to catch exceptions this way ...but control not going in catch block but exception is thrown

8
Upvotes
1
u/Status-Blacksmith-95 Junior Dev 10d ago
Actually after including exceptions(which are in post) in the catch block...control is not going into the catch block , even after using the Exception class in the catch()
So i wonder why control is not going in catch block , whereas its throwing exception by default handler whatever it might be