Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChangeFeedProcessor: Adds ChangeFeedProcessorUserException for detailed error notification #2807

Merged
merged 2 commits into from
Oct 19, 2021

Conversation

ealsur
Copy link
Member

@ealsur ealsur commented Oct 19, 2021

#2787 missed adding ChangeFeedProcessorUserException to the GA package.

This type is useful to distinguish internal from user-related errors when creating on error notifications:

var notifyErrorAsync = (string LeaseToken, Exception exception) =>
    {
        if (exception is ChangeFeedProcessorUserException userException)
        {
             Console.WriteLine($"Lease {LeaseToken} processing failed with unhandled exception {userException.InnerException}");
             Console.WriteLine($"Diagnostics {userException.ExceptionContext.Diagnostics}");
             Console.WriteLine($"Headers {userException.ExceptionContext.Headers}");
        }
       else
       {
           // This could be matched for CosmosException to decide importance based in our guidelines
            Console.WriteLine($"Lease {LeaseToken} failed with {exception}");
       }
     } ;

ChangeFeedProcessor changeFeedProcessor = monitoredContainer
	.GetChangeFeedProcessorBuilder<ToDoItem>(processorName: "changeFeedSample", HandleChangesAsync)
		.WithInstanceName(instanceName)
		.WithErrorNotification(notifyErrorAsync)
		.WithLeaseContainer(leaseContainer)
		.Build();

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors|Removes) Description"

Internal should be used for PRs that have no customer impact. This flag is used to help generate the changelog to know which PRs should be included. Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@j82w j82w changed the title ChangeFeedProcessor: Add ChangeFeedProcessorUserException for detailed error notification ChangeFeedProcessor: Adds ChangeFeedProcessorUserException for detailed error notification Oct 19, 2021
@ealsur ealsur enabled auto-merge (squash) October 19, 2021 15:01
@ealsur ealsur merged commit 6ccc1a8 into master Oct 19, 2021
@ealsur ealsur deleted the users/ealsur/cfperrorpublic branch October 19, 2021 15:14
@ealsur ealsur mentioned this pull request Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants