Esempio n. 1
0
        protected void SetAuthenticationExceptionOnRequestState <T>(
            TransportRequestState <T> requestState,
            ElasticsearchAuthException exception,
            TaskCompletionSource <ElasticsearchResponse <T> > tcs)
        {
            var result = this.HandleAuthenticationException(requestState, exception);

            tcs.SetResult(result);
            requestState.SetResult(result);
        }
        protected ElasticsearchResponse <T> HandleAuthenticationException <T>(TransportRequestState <T> requestState, ElasticsearchAuthException exception)
        {
            if (requestState.ClientSettings.ThrowOnElasticsearchServerExceptions)
            {
                throw exception.ToElasticsearchServerException();
            }

            var response = ElasticsearchResponse.CloneFrom <T>(exception.Response, default(T));

            response.Request       = requestState.PostData;
            response.RequestUrl    = requestState.Path;
            response.RequestMethod = requestState.Method;
            return(response);
        }