예제 #1
0
        /// <inheritdoc />
        public async Task <FeedResponse <T> > ExecuteNextAsync(CancellationToken token = default)
        {
            if (!_hasLoggedQuery)
            {
                _logger.LogQueryExecution(
                    _queryContext.SqlQuerySpec,
                    _queryContext.FeedOptions?.PartitionKey?.ToString(),
                    _continuationToken,
                    _queryContext.FeedOptions?.MaxItemCount,
                    _queryContext.FeedOptions?.MaxConcurrency);
                _hasLoggedQuery = true;
            }

            try
            {
                FeedResponse <T> response = await _feedIterator.ReadNextAsync(token);

                _continuationToken = response.ContinuationToken;

                return(response);
            }
            catch (CosmosException ex)
            {
                // The SDK wraps exceptions we throw in handlers with a CosmosException.
                Exception fhirException = ex.InnerException as FhirException ?? ex.InnerException as MicrosoftHealthException;

                if (fhirException == null)
                {
                    _processor.ProcessErrorResponse(ex.StatusCode, ex.Headers, ex.Message);
                }

                throw;
            }
        }
예제 #2
0
        public override async Task <ResponseMessage> SendAsync(RequestMessage request, CancellationToken cancellationToken)
        {
            UpdateOptions(request);

            ResponseMessage response = await base.SendAsync(request, cancellationToken);

            await _cosmosResponseProcessor.ProcessResponse(response);

            if (!response.IsSuccessStatusCode)
            {
                await _cosmosResponseProcessor.ProcessErrorResponse(response);
            }

            return(response);
        }