ired,
            check_database,
            override_global_claim_validators,
            user_context,
        )
        if session is None:
            if session_required:
                raise Exception(&#34;Should never come here&#34;)
            base_req.set_session_as_none()
        else:
            base_req.set_session(session)
        return base_req.get_session()

    return func


async def session_exception_handler(
    request: Request, exc: SuperTokensError
) -&gt; JSONResponse:
    &#34;&