Skip to content
Discussion options

You must be logged in to vote

The Content you were reading via response.Error.Content is still there - it just needs one narrowing step after the v12 exception refactor.

In v12, IApiResponse.Error was widened from ApiException to ApiExceptionBase, the shared base of:

  • ApiException - the server responded (this is the one that carries Content, StatusCode, headers, etc.)
  • ApiRequestException - a transport-level failure (no response was received)

Content lives on ApiException, so response.Error.Content no longer compiles directly. Recover it like this:

// Preferred: safe narrowing to the response-side exception
if (response.HasResponseError(out var apiException))
{
    _logger.LogError(apiException, apiException.Content);
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mdjaracubas
Comment options

Answer selected by glennawatson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants