List of usage examples for org.springframework.web.servlet.mvc.method.annotation ExceptionHandlerExceptionResolver ExceptionHandlerExceptionResolver
public ExceptionHandlerExceptionResolver()
From source file:io.getlime.security.powerauth.app.server.WebApplicationConfig.java
@Override public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { super.configureHandlerExceptionResolvers(exceptionResolvers); exceptionResolvers.add(new RESTResponseExceptionResolver()); exceptionResolvers.add(new ExceptionHandlerExceptionResolver()); exceptionResolvers.add(new ResponseStatusExceptionResolver()); }
From source file:od.controller.tests.ControllerTests.java
protected ExceptionHandlerExceptionResolver createExceptionResolver() { ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver() { @Override/*from www . jav a 2s .co m*/ protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) { Method method = new ExceptionHandlerMethodResolver(AppControllerAdvice.class) .resolveMethod(exception); return new ServletInvocableHandlerMethod(new AppControllerAdvice(), method); } }; exceptionResolver.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
From source file:org.lightadmin.core.config.context.LightAdminContextConfiguration.java
@Override public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { ExceptionHandlerExceptionResolver exceptionHandlerResolver = new ExceptionHandlerExceptionResolver(); exceptionHandlerResolver.setCustomArgumentResolvers( Arrays.<HandlerMethodArgumentResolver>asList(new ServerHttpRequestMethodArgumentResolver())); exceptionHandlerResolver.afterPropertiesSet(); exceptionResolvers.add(exceptionHandlerResolver); }
From source file:com.tkmtwo.rest.config.RestConfig.java
@Bean public ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver() { ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver(); return resolver; }
From source file:org.exoplatform.acceptance.rest.administration.credential.CredentialCRUDControllerTest.java
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); }//from w w w. j a v a 2 s . c o m }; List<HttpMessageConverter<?>> messageConverters = new ArrayList<>(); messageConverters.add(new FormHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter()); messageConverters.add(new MappingJackson2HttpMessageConverter()); exceptionResolver.setMessageConverters(messageConverters); exceptionResolver.afterPropertiesSet(); return exceptionResolver; }
From source file:org.terasoluna.gfw.web.exception.HandlerExceptionResolverLoggingInterceptorTest.java
@Test public void testInvoke_ExceptionHandlerExceptionResolver_responseCode_1xx() throws Throwable { // do setup for test case. NullPointerException occurException = new NullPointerException("null pointer exception."); HttpServletResponse mockResponse = mock(HttpServletResponse.class); ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver(); when(mockMethodInvocation.proceed()).thenReturn("viewname"); when(mockMethodInvocation.getThis()).thenReturn(resolver); when(mockResponse.getStatus()).thenReturn(100); when(mockMethodInvocation.getArguments()) .thenReturn(new Object[] { null, mockResponse, null, occurException }); // do test./*from www . j av a2 s .c o m*/ testTarget.invoke(mockMethodInvocation); // do assert. verify(mockExceptionLogger, times(1)).info((Exception) any()); }
From source file:org.terasoluna.gfw.web.exception.HandlerExceptionResolverLoggingInterceptorTest.java
@Test public void testInvoke_responseCode_199() throws Throwable { // do setup for test case. NullPointerException occurException = new NullPointerException("null pointer exception."); HttpServletResponse mockResponse = mock(HttpServletResponse.class); ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver(); when(mockMethodInvocation.proceed()).thenReturn("viewname"); when(mockMethodInvocation.getThis()).thenReturn(resolver); when(mockResponse.getStatus()).thenReturn(199); when(mockMethodInvocation.getArguments()) .thenReturn(new Object[] { null, mockResponse, null, occurException }); // do test.//from w w w . j ava 2 s. c om testTarget.invoke(mockMethodInvocation); // do assert. verify(mockExceptionLogger, times(1)).info((Exception) any()); }
From source file:org.terasoluna.gfw.web.exception.HandlerExceptionResolverLoggingInterceptorTest.java
@Test public void testafterPropertiesSet() throws Throwable { testTarget = new HandlerExceptionResolverLoggingInterceptor(); testTarget.afterPropertiesSet();/*w w w . j a v a2 s. c o m*/ this.mockExceptionLogger = spy(testTarget.getExceptionLogger()); testTarget.setExceptionLogger(mockExceptionLogger); // do setup for test case. NullPointerException occurException = new NullPointerException("null pointer exception."); HttpServletResponse mockResponse = mock(HttpServletResponse.class); ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver(); when(mockMethodInvocation.proceed()).thenReturn("viewname"); when(mockMethodInvocation.getThis()).thenReturn(resolver); when(mockResponse.getStatus()).thenReturn(100); when(mockMethodInvocation.getArguments()) .thenReturn(new Object[] { null, mockResponse, null, occurException }); // do test. testTarget.invoke(mockMethodInvocation); // do assert. verify(mockExceptionLogger, times(1)).info((Exception) any()); }
From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.java
/** * Bean for looking up methods annotated with {@link org.springframework.web.bind.annotation.ExceptionHandler}. * // w ww .ja v a 2 s .co m * @return */ @Bean public ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver() { ExceptionHandlerExceptionResolver er = new ExceptionHandlerExceptionResolver(); er.setCustomArgumentResolvers(defaultMethodArgumentResolvers()); er.setMessageConverters(defaultMessageConverters()); configurerDelegate.configureExceptionHandlerExceptionResolver(er); configureExceptionHandlerExceptionResolver(er); return er; }