I have problems understanding on why ExceptionHandlerExceptionResolver throws an Exception. I have written a custom @RestControllerAdvice ExceptionHandler to catch Exceptions thrown by my Spring Boot application. After the catch my ExceptionHandler returns as a response the message from the thrown exception. But I still get a log message from ExceptionHandlerExceptionResolver and I can't figure out why.
Here the Log message:
2022-05-04 10:08:53.043 INFO 17600 --- [nio-8080-exec-3] at.sds.wm.common.CommonExceptionHandler : Equipment Barbell 660Kg exists already. Either id already taken or name combined with same equipment already saved
2022-05-04 10:08:53.049 WARN 17600 --- [nio-8080-exec-3] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [at.sds.wm.equipment.exceptions.EquipmentExistsAlreadyException: Equipment Barbell 660Kg exists already. Either id already taken or name combined with same equipment already saved]
I first thought, that the ExceptionHandlerExceptionResolver gets called because my ExceptionHandler throws an Exception but that isn't the case.
Any tips and tricks on how to surpress the second Log, or could someone explain me why the ExceptionHandlerExceptionResolver gets called?
Below my code snippet for the ExceptionHandler part that gets called:
@ExceptionHandler(value = {WorkoutExistsAlreadyException.class, EquipmentExistsAlreadyException.class, ExerciseExistsAlreadyException.class})
@ResponseStatus(code = HttpStatus.CONFLICT)
public String handleExistsAlreadyException(RuntimeException ex) {
log.info(ex.getMessage());
return ex.getMessage();
}