Esempio n. 1
0
        private async Task <CosmosQueryResponse> QueryRequestExecutor(
            string continuationToken,
            object state,
            CancellationToken cancellationToken)
        {
            DocumentQuery <CosmosQueryResponse> documentQuery = (DocumentQuery <CosmosQueryResponse>)state;

            // DEVNOTE: Remove try catch once query pipeline is converted to exceptionless
            try
            {
                return(await documentQuery.ExecuteNextQueryStreamAsync(cancellationToken));
            }
            catch (DocumentClientException exception)
            {
                return(new CosmosQueryResponse(
                           errorMessage: exception.Message,
                           httpStatusCode: exception.StatusCode.HasValue ? exception.StatusCode.Value : HttpStatusCode.InternalServerError,
                           retryAfter: exception.RetryAfter));
            }catch (AggregateException ae)
            {
                DocumentClientException exception = ae.InnerException as DocumentClientException;
                if (exception == null)
                {
                    throw;
                }

                return(new CosmosQueryResponse(
                           errorMessage: exception.Message,
                           httpStatusCode: exception.StatusCode.HasValue ? exception.StatusCode.Value : HttpStatusCode.InternalServerError,
                           retryAfter: exception.RetryAfter));
            }
        }