I went through link: How to find controller name in @controllerAdvice or @RestControllerAdvice in Spring MVC? many times, but I am looking to get the Controller methodname in @ControllerAdvice class.
Here is my CustomHandler Class.
@ControllerAdvice
public class CustomExceptionHandler extends ResponseEntityExceptionHandler {
........
..........
..........
@ExceptionHandler({DataExistsException.class})
public ResponseEntity<Object> handleDataExistsException(RuntimeException e, WebRequest request, HttpServletRequest httpRequest, HttpServletResponse response, HandlerMethod handlerMethod) {
// Here I am looking to print Controller endpoint method name
LoggingUtil.printJsonReq(httpRequest, HttpStatus.valueOf("BAD_REQUEST").value(), LoggingUtil.getTime(httpRequest), null, response);
return handleExceptionInternal(e, getErrors(error), getHeaders(), HttpStatus.BAD_REQUEST, request);
}
}