public void renderException(final Exception ex, final HttpServletResponse response) {
        val map = new HashMap<String, Object>();
        map.put("error", ex.getMessage());
        map.put("stacktrace", Arrays.deepToString(ex.getStackTrace()));
        renderException(map, response);
    }
Render exceptions. Adds error messages and the stack trace to the json model
and sets the response status accordingly to note bad requests.

@param ex       the ex
@param response the response
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/JsonUtils.java