Skip to content

Commit

Permalink
ChangeFeed: Adds MalformedContinuationToken SubstatusCode to exception (
Browse files Browse the repository at this point in the history
  • Loading branch information
NaluTripician committed Jul 15, 2024
1 parent 3fd2ce6 commit 6e1d40d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ internal override CosmosException Visit(
{
return CosmosExceptionFactory.CreateBadRequestException(
message: malformedChangeFeedContinuationTokenException.Message,
headers: new Headers(),
headers: new Headers()
{
SubStatusCode = Documents.SubStatusCodes.MalformedContinuationToken
},
stackTrace: malformedChangeFeedContinuationTokenException.StackTrace,
innerException: malformedChangeFeedContinuationTokenException,
trace: trace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3319,6 +3319,23 @@ await CosmosItemTests.GivenItemAsyncWhenMissingMemberHandlingIsErrorThenExpectsC
id: itemIdThatWillNotExist,
partitionKey: new Cosmos.PartitionKey(partitionKeyValue),
cancellationToken: cancellationToken));
}

[TestMethod]
public async Task MalformedChangeFeedContinuationTokenSubStatusCodeTest()
{
FeedIterator badIterator = this.Container.GetChangeFeedStreamIterator(
ChangeFeedStartFrom.ContinuationToken("AMalformedContinuationToken"),
ChangeFeedMode.Incremental,
new ChangeFeedRequestOptions()
{
PageSizeHint = 100
});

ResponseMessage response = await badIterator.ReadNextAsync();

Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
Assert.AreEqual(SubStatusCodes.MalformedContinuationToken, response.Headers.SubStatusCode);
}

private static async Task GivenItemStreamAsyncWhenMissingMemberHandlingIsErrorThenExpectsCosmosExceptionTestAsync(
Expand Down

0 comments on commit 6e1d40d

Please sign in to comment.