@Override
    public ModelAndView resolveException(
        @Nonnull
        final HttpServletRequest request,
        @Nonnull
        final HttpServletResponse response, final Object handler,
        @Nonnull
        final Exception exception) {

        if (!(exception instanceof FlowExecutionRepositoryException) || exception instanceof BadlyFormattedFlowExecutionKeyException) {
            LOGGER.debug("Ignoring the received exception [{}] due to a type mismatch with handler [{}]", exception, handler);
            return null;
        }

        val urlToRedirectTo = request.getRequestURI()
            + (request.getQueryString() != null ? '?'
            + request.getQueryString() : StringUtils.EMPTY);

        LOGGER.debug("Error getting flow information for URL [{}]", urlToRedirectTo, exception);
        val model = new HashMap<String, Object>();
        model.put(this.modelKey, StringEscapeUtils.escapeHtml4(exception.getMessage()));

        return new ModelAndView(new RedirectView(urlToRedirectTo), model);
    }
Since FlowExecutionRepositoryException is a common ancestor to these exceptions and other
error cases we would likely want to hide from the user, it seems reasonable to check for
FlowExecutionRepositoryException.
<p>
BadlyFormattedFlowExecutionKeyException is specifically ignored by this handler
because redirecting to the requested URI with this exception may cause an infinite
redirect loop (i.e. when invalid "execution" parameter exists as part of the query string
support/cas-server-support-actions-core/src/main/java/org/apereo/cas/web/FlowExecutionExceptionResolver.java