Want to handle the exception from only exceptionhandler class of API. Is there any way can remove all the try-catch of the API.
Using the @exceptionhandler but purpose not solved from this approach. Is there any way don't required try catch?
Want to handle the exception from only exceptionhandler class of API. Is there any way can remove all the try-catch of the API.
Using the @exceptionhandler but purpose not solved from this approach. Is there any way don't required try catch?
Copyright © 2021 Jogjafile Inc.
Sure, all you need is a class with a
@ControllerAdviceannotation on top of it, and to make it extendsResponseEntityExceptionHandlerex:And of course you need to remove the
try-catchor re-throw the exceptions otherwise they wont be catched by theControllerAdvice.see: https://docs.spring.io/spring-framework/docs/6.1.2/javadoc-api/org/springframework/web/bind/annotation/ControllerAdvice.html