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

EF Core probably should have an option to not log OperationCanceledExceptions #28406

Closed
DoctorKrolic opened this issue Jul 9, 2022 · 2 comments

Comments

@DoctorKrolic
Copy link
Contributor

I have a code sample like this:

try
{
  await db.SaveChangesAsync(cancellationToken);
}
catch (OperationCanceledException)
{
 // my custom logic to handle cancels
}

This setup, however, doesn't stop EF Core and it still logs OperationCanceledException to the console as a fail with the whole stack trace. I verified this by putting a break point at the first statement in the catch block. When break point is hit, the log entry is already there. I've found it rather inconvinient, because I now have to either live with an overflown by this exceptions log or disable all errors from Microsoft.EntityFrameworkCore.Update, so if something bad happens, it will not log the really valuable exception. It would be nice IMO if there is a flag, that indicates whether EF Core logs OperationCanceledExceptions (and maybe TaskCanceledExceptions) or not. It should probably be enabled by default, because these exceptions are usually used in a normal non-exceptional code pathes

@ajcvickers
Copy link
Contributor

Duplicate of #19526.

@DoctorKrolic
Copy link
Contributor Author

Nice!

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants