private ModelAndView getModelAndView(Method handlerMethod,
                                         ServletWebRequest webRequest, MapEntry exceptionProcessor,
                                         Exception ex) throws Exception {

        HttpStatus responseStatus = exceptionProcessor.httpStatus();
        webRequest.getResponse().setStatus(responseStatus.value());

        ErrorBody returnValue = new ErrorBody();
        returnValue.setErrorCode(responseStatus.value());

        String message = StringUtils.hasText(exceptionProcessor.message()) ? exceptionProcessor
                .message() : ex.getMessage();
        returnValue.setMessage(message);

        if (returnValue != null
                && AnnotationUtils.findAnnotation(handlerMethod,
                ResponseBody.class) != null) {
            return handleResponseBody(returnValue, webRequest);
        }

        throw new IllegalArgumentException(
                "Invalid handler method return value: " + returnValue);
    }