Google-cloud-dotnet: IExceptionLogger in Google.Cloud.Diagnostics.AspNetCore should accept null HttpContext

Created on 3 Mar 2020  路  1Comment  路  Source: googleapis/google-cloud-dotnet

Is your feature request related to a problem? Please describe.

Describe the solution you'd like
When you use the IExceptionLogger outside of a http context it throws an ArgumentNullException. You can pass in a null http context but it tries to resolve the context from the IHttpContextAccessor. If f it is not in a request scope the accessor returns null and then the method crashs.

This is strange because it seems that the request url and other request information are optional anyway:
https://github.com/googleapis/google-cloud-dotnet/blob/master/apis/Google.Cloud.Diagnostics.AspNetCore/Google.Cloud.Diagnostics.AspNetCore/ErrorReporting/HttpContextWrapper.cs#L35

I would make the http context really optional and the wrapper to this:
https://gist.github.com/SebastianStehle/294719e0cf2f2f6f71b808623b1b458c

logging p1 investigating bug

Most helpful comment

This should be fixed by #4521 .
Thanks for reporting.

>All comments

This should be fixed by #4521 .
Thanks for reporting.

Was this page helpful?
0 / 5 - 0 ratings