protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) { Class<?> handlerType = handlerMethod.getBeanType(); Method method = getExceptionHandlerMethodResolver(handlerType).resolveMethod(exception); if (method != null) { return new ServletInvocableHandlerMethod(handlerMethod.getBean(), method); } try { method = getClass().getMethod("getFailedResult", new Class[] { Exception.class }); } catch (Exception e) { } return new ServletInvocableHandlerMethod(this, method); }
@Override public ServletInvocableHandlerMethod createInvocableHandlerMethod(HandlerMethod handlerMethod) { ServletInvocableHandlerMethod invocableHandlerMethod; if (creator != null) { invocableHandlerMethod = creator.createInvocableHandlerMethod(handlerMethod); if (invocableHandlerMethod != null) { return invocableHandlerMethod; } } return new ServletInvocableHandlerMethod(handlerMethod); }
private ExceptionHandlerExceptionResolver createExceptionResolver() { ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver() { protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) { Method method = new ExceptionHandlerMethodResolver(JsonErrorHandler.class).resolveMethod(exception); return new ServletInvocableHandlerMethod(jsonErrorHandler, method); } }; List<HttpMessageConverter<?>> messageConverters = new ArrayList<>(); messageConverters.add(new FormHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter()); messageConverters.add(new MappingJackson2HttpMessageConverter()); exceptionResolver.setMessageConverters(messageConverters); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
@Override protected ServletInvocableHandlerMethod createInvocableHandlerMethod(HandlerMethod handlerMethod) { return invocableHandlerMethodCreator.createInvocableHandlerMethod(handlerMethod); }
ServletInvocableHandlerMethod createInvocableHandlerMethod(HandlerMethod handlerMethod);