Puoi gestire le eccezioni con Spring AOP, @Aspect
public class ErrorInterceptor{
@AfterThrowing(pointcut = "execution(* your.package..* (..))", throwing = "ex")
public void errorInterceptorForSerializationException(SerializationException ex) {
// DO SOMETHING HERE WITH EX
logger.error( ex.getCause().getMessage());
}
@AfterThrowing(pointcut = "execution(* your.package..* (..))", throwing = "ex")
public void errorInterceptorForSerializationFailedException(SerializationFailedException ex) {
// DO SOMETHING HERE WITH EX
logger.error( ex.getCause().getMessage());
}
}