code: protected void error(HttpServletRequest httpRequest, HttpServletResponse httpResponse, Exception error)
        throws ExternalAuthenticationException, IOException {
  
      final String key = this.getExternalAuthenticationKey(httpRequest);
  
      if (error instanceof IdpErrorStatusException) {
        Status s = ((IdpErrorStatusException) error).getStatus();
        if (s.getStatusCode() == null || StatusCode.SUCCESS.equals(s.getStatusCode().getValue())) {
          throw new IllegalArgumentException("Bad call to error - Status is successful");
        }
        ProfileRequestContext<?, ?> profileRequestContext = this.getProfileRequestContext(httpRequest);
        profileRequestContext.addSubcontext(new ProxiedStatusContext(s), true);
      }
  
      httpRequest.setAttribute(ExternalAuthentication.AUTHENTICATION_EXCEPTION_KEY, error);
      ExternalAuthentication.finishExternalAuthentication(key, httpRequest, httpResponse);
      httpRequest.getSession().removeAttribute(EXTAUTHN_KEY_ATTRIBUTE_NAME);
    }
docs: Method that should be invoked to exit the external authentication process with an error.
  
  @param httpRequest
  the HTTP request
  @param httpResponse
  the HTTP response
  @param error
  the error exception
  @throws ExternalAuthenticationException
  for Shibboleth session errors
  @throws IOException
  for IO errors
  @see #error(HttpServletRequest, HttpServletResponse, String)
  @see #error(HttpServletRequest, HttpServletResponse, Status)