Spring Framework ResponseStatusExceptionResolver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ResponseStatusExceptionResolver class.

This code example shows how to use the following methods:
@Component 
public class GlobalExceptionResolver implements HandlerExceptionResolver { 
 
	private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionResolver.class); 
	 
	private final ResponseStatusExceptionResolver annotatedExceptionHandler = new ResponseStatusExceptionResolver(); 
	 
	private final DefaultHandlerExceptionResolver defaultExceptionHandler = new DefaultHandlerExceptionResolver(); 
		 
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { 
		try { 
			if (ex instanceof EmptyResultDataAccessException) { 
				return handleEmptyResultDataAccessException((EmptyResultDataAccessException) ex, request, response, handler); 
			} 
		} catch (Exception e) { 
			logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in Exception", ex); 
			return null; 
		} 
		ModelAndView result = annotatedExceptionHandler.resolveException(request, response, handler, ex); 
		if (result != null) { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver; 
 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
public class MessageAwareResponseStatusExceptionResolver extends ResponseStatusExceptionResolver { 
 
  @Override 
  public int getOrder() { 
    return Ordered.HIGHEST_PRECEDENCE; 
  } 
 
  @Override 
  protected ModelAndView resolveResponseStatus(ResponseStatus responseStatus, HttpServletRequest request, 
                                               HttpServletResponse response, Object handler, Exception ex) throws Exception { 
    int statusCode = responseStatus.value().value(); 
    String reason = responseStatus.reason(); 
    if (!StringUtils.hasLength(reason)) { 
      response.sendError(statusCode, ex.getMessage()); 
    } else { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: