use of com.epam.ta.reportportal.commons.exception.rest.ReportPortalExceptionResolver in project service-authorization by reportportal.
the class WebMvcConfig method configureHandlerExceptionResolvers.
@Override
public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
RestErrorDefinition<Exception> authErrorDefinition = new RestErrorDefinition<>(HttpStatus.BAD_REQUEST, ErrorType.ACCESS_DENIED, new DefaultExceptionMessageBuilder());
Map<Class<? extends Throwable>, RestErrorDefinition> errorMappings = ImmutableMap.<Class<? extends Throwable>, RestErrorDefinition>builder().put(OAuth2Exception.class, authErrorDefinition).put(AuthenticationException.class, authErrorDefinition).put(UsernameNotFoundException.class, authErrorDefinition).putAll(ExceptionMappings.DEFAULT_MAPPING).build();
RestExceptionHandler handler = new RestExceptionHandler();
handler.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
handler.setErrorResolver(new ReportPortalExceptionResolver(new DefaultErrorResolver(errorMappings)));
handler.setMessageConverters(messageConverters.getConverters());
exceptionResolvers.add(handler);
}
Aggregations