use of org.entando.entando.web.common.handlers.RestExceptionHandler in project entando-core by entando.
the class AbstractControllerTest method createExceptionResolver.
protected ExceptionHandlerExceptionResolver createExceptionResolver() {
final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("rest/messages");
messageSource.setUseCodeAsDefaultMessage(true);
ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver() {
@Override
protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) {
Method method = new ExceptionHandlerMethodResolver(RestExceptionHandler.class).resolveMethod(exception);
RestExceptionHandler validationHandler = new RestExceptionHandler();
validationHandler.setMessageSource(messageSource);
return new ServletInvocableHandlerMethod(validationHandler, method);
}
};
exceptionResolver.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
exceptionResolver.afterPropertiesSet();
return exceptionResolver;
}
Aggregations