}
private void handleExceptionFromFilterChain(Exception e, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException {
RuntimeException ase = (ApiException) throwableAnalyzer.getFirstThrowableOfType(ApiException.class, throwableAnalyzer.determineCauseChain(e));
if (ase != null && ase instanceof ApiException) {
ApiException apiException = (ApiException) ase;
if (logger.isDebugEnabled()) {
logger.debug("API Exception: " + e.getMessage());
}
if (apiException instanceof NotAuthorizedException || apiException instanceof OperationNotPermittedException) {
if (logger.isDebugEnabled()) {
logger.debug("Redirecting for refresh of " + apiException.getProviderId() + " connection.");
}
httpResponse.sendRedirect(getRefreshUrl(httpRequest, apiException));
return;
}
}