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

Improve message of ODataError #1958

Closed
olivermue opened this issue Jun 9, 2023 · 1 comment
Closed

Improve message of ODataError #1958

olivermue opened this issue Jun 9, 2023 · 1 comment

Comments

@olivermue
Copy link

Is your feature request related to a problem? Please describe.
Whenever the graph interface returns a 4XX or 5XX status code it will be deserialized into an ODataError exception, containing the corresponding error including all received information within the property Error. The outer exception has also a message property, but it always contains only the message Exception of type 'Microsoft.Graph.Models.ODataErrors.ODataError' was thrown..

Whenever this error happens at runtime on places where we didn't expect them, all we can see in generic visualizers of exceptions (e.g. Application Insights or a Hangfire Failed Job) is something like this:

Microsoft.Graph.Models.ODataErrors.ODataError: Exception of type 'Microsoft.Graph.Models.ODataErrors.ODataError' was thrown.
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponse(HttpResponseMessage response, Dictionary'2 errorMapping, Activity activityForAttributes)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory'1 factory, Dictionary'2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory'1 factory, Dictionary'2 errorMapping, CancellationToken cancellationToken)

This information is useless, cause we can't immeditately see, what the error response was from graph itself. Instead we have to dig deeper or locally rerun the given method and hope we will see the same error again.

Describe the solution you'd like
It would be much easier, if the message property of the ODataError would contain the very same error message that Error.Message contains. Maybe even better would be something like $"{Error.Code}: {Error.Message}" if available. If the returned error doesn't contain any such information the fallback to the given generic error message would be sufficient.

Describe alternatives you've considered
In our case we mostly look at App Insights or Hangfire failed jobs, which visualize the exception in a generic way by only showing the exception type and the content of the exception message property. We could enhance both places to check for the concrete exception type and in case of being an ODataError, visualize the inner Error property. But that would mean, that everybody has to take care for this specific exception type in all places where they are visualized (e.g. Loggers, etc.)

@andrueastman
Copy link
Member

Clsoing this for now as this is related to #2094 and was resolved
via #2130

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

2 participants