private QueryResponse( IEnumerable <CosmosElement> result, int count, long responseLengthBytes, CosmosQueryResponseMessageHeaders responseHeaders, HttpStatusCode statusCode, RequestMessage requestMessage, CosmosDiagnostics diagnostics, string errorMessage, Error error) : base( statusCode: statusCode, requestMessage: requestMessage, errorMessage: errorMessage, error: error, headers: responseHeaders, diagnostics: diagnostics) { this.CosmosElements = result; this.Count = count; this.ResponseLengthBytes = responseLengthBytes; this.memoryStream = new Lazy <MemoryStream>(() => CosmosElementSerializer.ToStream( this.QueryHeaders.ContainerRid, this.CosmosElements, this.QueryHeaders.ResourceType, this.CosmosSerializationOptions)); }
private static string GetMessageHelper( HttpStatusCode statusCode, Headers headers, string responseBody, CosmosDiagnostics diagnostics) { StringBuilder stringBuilder = new StringBuilder(); CosmosException.AppendMessageWithoutDiagnostics( stringBuilder, statusCode, headers, responseBody); // Include the diagnostics for exceptions where it is critical // to root cause failures. if (statusCode == HttpStatusCode.RequestTimeout || statusCode == HttpStatusCode.InternalServerError || statusCode == HttpStatusCode.ServiceUnavailable || (statusCode == HttpStatusCode.NotFound && headers.SubStatusCode == SubStatusCodes.ReadSessionNotAvailable)) { stringBuilder.Append("; Diagnostics:"); stringBuilder.Append(diagnostics.ToString()); } return(stringBuilder.ToString()); }
internal static QueryResponse CreateSuccess( IEnumerable <CosmosElement> result, int count, long responseLengthBytes, CosmosQueryResponseMessageHeaders responseHeaders, CosmosDiagnostics diagnostics) { if (count < 0) { throw new ArgumentOutOfRangeException("count must be positive"); } if (responseLengthBytes < 0) { throw new ArgumentOutOfRangeException("responseLengthBytes must be positive"); } QueryResponse cosmosQueryResponse = new QueryResponse( result: result, count: count, responseLengthBytes: responseLengthBytes, responseHeaders: responseHeaders, diagnostics: diagnostics, statusCode: HttpStatusCode.OK, errorMessage: null, error: null, requestMessage: null); return(cosmosQueryResponse); }
private QueryResponse( IEnumerable <CosmosElement> result, int count, long responseLengthBytes, CosmosQueryResponseMessageHeaders responseHeaders, HttpStatusCode statusCode, RequestMessage requestMessage, CosmosDiagnostics diagnostics, string errorMessage, Error error, Lazy <MemoryStream> memoryStream, CosmosSerializationFormatOptions serializationOptions) : base( statusCode: statusCode, requestMessage: requestMessage, errorMessage: errorMessage, error: error, headers: responseHeaders, diagnostics: diagnostics) { this.CosmosElements = result; this.Count = count; this.ResponseLengthBytes = responseLengthBytes; this.memoryStream = memoryStream; this.CosmosSerializationOptions = serializationOptions; }
/// <summary> /// Create an instance of CosmosOperationCanceledException /// </summary> /// <param name="originalException">The original operation canceled exception</param> /// <param name="diagnostics"></param> public CosmosOperationCanceledException( OperationCanceledException originalException, CosmosDiagnostics diagnostics) : base(originalException.CancellationToken) { this.originalException = originalException ?? throw new ArgumentNullException(nameof(originalException)); this.Diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics)); }
/// <summary> /// Create an instance of CosmosOperationCanceledException /// </summary> /// <param name="originalException">The original operation canceled exception</param> /// <param name="diagnostics"></param> public CosmosOperationCanceledException( OperationCanceledException originalException, CosmosDiagnostics diagnostics) : base(originalException.CancellationToken) { this.originalException = originalException ?? throw new ArgumentNullException(nameof(originalException)); this.Diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics)); this.tokenCancellationRequested = originalException.CancellationToken.IsCancellationRequested; this.toStringMessage = this.CreateToStringMessage(); this.lazyMessage = this.CreateLazyMessage(); }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the CosmosResponseMessage /// </summary> internal ItemResponse( HttpStatusCode httpStatusCode, Headers headers, T item, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = item; this.Diagnostics = diagnostics; }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the HttpResponseMessage /// </summary> internal ThroughputResponse( HttpStatusCode httpStatusCode, Headers headers, ThroughputProperties throughputProperties, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = throughputProperties; this.Diagnostics = diagnostics; }
protected ReadFeedResponse( HttpStatusCode httpStatusCode, ICollection <T> resource, Headers responseMessageHeaders, CosmosDiagnostics diagnostics) { this.Count = resource.Count; this.Headers = responseMessageHeaders; this.Resource = resource; this.StatusCode = httpStatusCode; this.Diagnostics = diagnostics; }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the HttpResponseMessage /// </summary> internal UserResponse( HttpStatusCode httpStatusCode, Headers headers, UserProperties userProperties, User user, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = userProperties; this.User = user; this.Diagnostics = diagnostics; }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the HttpResponseMessage /// </summary> internal ContainerResponse( HttpStatusCode httpStatusCode, Headers headers, ContainerProperties containerProperties, Container container, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = containerProperties; this.Container = container; this.Diagnostics = diagnostics; }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the CosmosResponseMessage /// </summary> internal ItemResponse( HttpStatusCode httpStatusCode, Headers headers, T item, CosmosDiagnostics diagnostics, RequestMessage requestMessage) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = item; this.Diagnostics = diagnostics; this.RequestMessage = requestMessage; }
internal ReadFeedResponse( HttpStatusCode httpStatusCode, IEnumerable <T> resources, int resourceCount, Headers responseMessageHeaders, CosmosDiagnostics diagnostics) { this.Count = resourceCount; this.Headers = responseMessageHeaders; this.StatusCode = httpStatusCode; this.Diagnostics = diagnostics; this.Resource = resources; }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the HttpResponseMessage /// </summary> internal DatabaseResponse( HttpStatusCode httpStatusCode, Headers headers, DatabaseProperties databaseProperties, Database database, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = databaseProperties; this.Database = database; this.Diagnostics = diagnostics; }
internal BatchResponse( HttpStatusCode statusCode, SubStatusCodes subStatusCode, string errorMessage, double requestCharge, TimeSpan?retryAfter, string activityId, CosmosDiagnostics cosmosDiagnostics, ServerBatchRequest serverRequest, CosmosSerializer serializer) : this(statusCode, subStatusCode, errorMessage, requestCharge, retryAfter, activityId, cosmosDiagnostics, serverRequest.Operations, serializer) { }
/// <summary> /// A private constructor to ensure the factory is used to create the object. /// This will prevent memory leaks when handling the HttpResponseMessage /// </summary> internal PermissionResponse( HttpStatusCode httpStatusCode, Headers headers, PermissionProperties permissionProperties, Permission permission, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = permissionProperties; this.Permission = permission; this.Diagnostics = diagnostics; }
// A non-public constructor to ensure the factory is used to create the object. // This will prevent memory leaks when handling the HttpResponseMessage. internal ClientEncryptionKeyResponse( HttpStatusCode httpStatusCode, Headers headers, ClientEncryptionKeyProperties keyProperties, ClientEncryptionKey key, CosmosDiagnostics diagnostics) { this.StatusCode = httpStatusCode; this.Headers = headers; this.Resource = keyProperties; this.ClientEncryptionKey = key; this.Diagnostics = diagnostics; }
/// <summary> /// Create a <see cref="ResponseMessage"/> /// </summary> /// <param name="statusCode">The HttpStatusCode of the response</param> /// <param name="requestMessage">The <see cref="Cosmos.RequestMessage"/> object</param> /// <param name="errorMessage">The reason for failures if any.</param> /// <param name="error">The inner error object</param> /// <param name="headers">The headers for the response.</param> /// <param name="diagnostics">The diagnostics for the request</param> internal ResponseMessage( HttpStatusCode statusCode, RequestMessage requestMessage, string errorMessage, Error error, Headers headers, CosmosDiagnostics diagnostics) { this.StatusCode = statusCode; this.RequestMessage = requestMessage; this.ErrorMessage = errorMessage; this.Error = error; this.Headers = headers; this.Diagnostics = diagnostics; }
protected ReadFeedResponse( HttpStatusCode httpStatusCode, CosmosArray cosmosArray, CosmosSerializerCore serializerCore, Headers responseMessageHeaders, CosmosDiagnostics diagnostics) { this.Count = cosmosArray.Count; this.Headers = responseMessageHeaders; this.StatusCode = httpStatusCode; this.Diagnostics = diagnostics; this.Resource = CosmosElementSerializer.GetResources <T>( cosmosArray: cosmosArray, serializerCore: serializerCore); }
private TransactionalBatchResponse( HttpStatusCode statusCode, SubStatusCodes subStatusCode, string errorMessage, double requestCharge, TimeSpan?retryAfter, string activityId, CosmosDiagnostics cosmosDiagnostics, IReadOnlyList <ItemBatchOperation> operations, CosmosSerializerCore serializer) { this.StatusCode = statusCode; this.SubStatusCode = subStatusCode; this.ErrorMessage = errorMessage; this.Operations = operations; this.SerializerCore = serializer; this.RequestCharge = requestCharge; this.RetryAfter = retryAfter; this.ActivityId = activityId; this.Diagnostics = cosmosDiagnostics; }
internal static QueryResponse CreateFailure( CosmosQueryResponseMessageHeaders responseHeaders, HttpStatusCode statusCode, RequestMessage requestMessage, string errorMessage, Error error, CosmosDiagnostics diagnostics) { QueryResponse cosmosQueryResponse = new QueryResponse( result: Enumerable.Empty <CosmosElement>(), count: 0, responseLengthBytes: 0, responseHeaders: responseHeaders, diagnostics: diagnostics, statusCode: statusCode, errorMessage: errorMessage, error: error, requestMessage: requestMessage); return(cosmosQueryResponse); }
internal static QueryResponse CreateSuccess( IEnumerable <CosmosElement> result, int count, long responseLengthBytes, CosmosQueryResponseMessageHeaders responseHeaders, CosmosDiagnostics diagnostics, CosmosSerializationFormatOptions serializationOptions) { if (count < 0) { throw new ArgumentOutOfRangeException("count must be positive"); } if (responseLengthBytes < 0) { throw new ArgumentOutOfRangeException("responseLengthBytes must be positive"); } Lazy <MemoryStream> memoryStream = new Lazy <MemoryStream>(() => CosmosElementSerializer.ToStream( responseHeaders.ContainerRid, result, responseHeaders.ResourceType, serializationOptions)); QueryResponse cosmosQueryResponse = new QueryResponse( result: result, count: count, responseLengthBytes: responseLengthBytes, responseHeaders: responseHeaders, diagnostics: diagnostics, statusCode: HttpStatusCode.OK, errorMessage: null, error: null, requestMessage: null, memoryStream: memoryStream, serializationOptions: serializationOptions); return(cosmosQueryResponse); }
internal static QueryResponse CreateFailure( CosmosQueryResponseMessageHeaders responseHeaders, HttpStatusCode statusCode, RequestMessage requestMessage, string errorMessage, Error error, CosmosDiagnostics diagnostics) { QueryResponse cosmosQueryResponse = new QueryResponse( result: new List <CosmosElement>(), count: 0, responseLengthBytes: 0, responseHeaders: responseHeaders, diagnostics: diagnostics, statusCode: statusCode, errorMessage: errorMessage, error: error, requestMessage: requestMessage, memoryStream: null, serializationOptions: null); return(cosmosQueryResponse); }
public void AppendDiagnostics(CosmosDiagnostics diagnostics) { this.cosmosDiagnostics.Add(diagnostics); }