protected Object handleException(final Exception e, final HttpActionAdapter httpActionAdapter, final WebContext context) {
        if (httpActionAdapter == null || context == null) {
            throw runtimeException(e);
        } else if (e instanceof HttpAction httpAction) {
            LOGGER.debug("extra HTTP action required in security: {}", httpAction.getCode());
            return httpActionAdapter.adapt(httpAction, context);
        } else {
            if (StringUtils.isNotBlank(errorUrl)) {
                val action = HttpActionHelper.buildRedirectUrlAction(context, errorUrl);
                return httpActionAdapter.adapt(action, context);
            } else {
                throw runtimeException(e);
            }
        }
    }
Handle exceptions.

@param e the thrown exception
@param httpActionAdapter the HTTP action adapter
@param context the web context
@return the final HTTP result
pac4j-core/src/main/java/org/pac4j/core/engine/AbstractExceptionAwareLogic.java