Summary
Users upgrading to v12 report they can no longer find response.Error.Content on an IApiResponse<T>. The data is still there — but the access pattern changed in the v11/v12 exception refactor and the migration path, while technically documented, is not discoverable enough. This issue tracks improving the docs/upgrade notes (this is not a code defect).
Reported in discussion #2187.
What actually changed
IApiResponse<T>.Error was widened from ApiException? to ApiExceptionBase? (src/Refit/ApiResponse{T}.cs:121), the shared base of ApiException (server responded) and ApiRequestException (transport failure).
- The response body
Content still lives on the derived ApiException (src/Refit/ApiException.cs:162); ApiExceptionBase only exposes RequestContent.
- Net effect:
response.Error.Content no longer compiles, so users assume the feature was removed. It wasn't — it just needs a narrowing step.
Correct usage in v12
// Preferred: safe narrowing to the response-side exception
if (response.HasResponseError(out var apiException))
{
_logger.LogError(apiException, apiException.Content);
}
// Or a direct cast / pattern match
var content = (response.Error as ApiException)?.Content;
Why it's hard to find
- The README breaking-changes section (lines ~187–191) explains the
Error type change and points at HasResponseError(...), and there's a worked example (lines ~2068–2071) using responseError.Content — but neither is keyed off the symptom users actually hit ("Error.Content doesn't exist anymore").
- Nothing connects the old
Error.Content expression to the new HasResponseError/cast pattern, so a Ctrl-F for "Content" doesn't lead a migrating user to the fix.
Proposed documentation changes
- Add an explicit before/after migration snippet in the v12 upgrade notes:
- Before:
var body = response.Error.Content;
- After:
response.HasResponseError(out var e) → e.Content (and mention the (Error as ApiException)?.Content shorthand).
- Cross-reference this from the exception-handling section so searching for "Error.Content" or "Content" lands on the migration note.
- Optional: a short FAQ/troubleshooting entry ("
response.Error.Content no longer compiles after upgrading to v12") pointing at HasResponseError.
Out of scope
No runtime/API change. If a future ergonomic helper is desired (e.g. a convenience accessor for response content on IApiResponse), that should be a separate enhancement proposal, not part of this docs fix.
Summary
Users upgrading to v12 report they can no longer find
response.Error.Contenton anIApiResponse<T>. The data is still there — but the access pattern changed in the v11/v12 exception refactor and the migration path, while technically documented, is not discoverable enough. This issue tracks improving the docs/upgrade notes (this is not a code defect).Reported in discussion #2187.
What actually changed
IApiResponse<T>.Errorwas widened fromApiException?toApiExceptionBase?(src/Refit/ApiResponse{T}.cs:121), the shared base ofApiException(server responded) andApiRequestException(transport failure).Contentstill lives on the derivedApiException(src/Refit/ApiException.cs:162);ApiExceptionBaseonly exposesRequestContent.response.Error.Contentno longer compiles, so users assume the feature was removed. It wasn't — it just needs a narrowing step.Correct usage in v12
Why it's hard to find
Errortype change and points atHasResponseError(...), and there's a worked example (lines ~2068–2071) usingresponseError.Content— but neither is keyed off the symptom users actually hit ("Error.Contentdoesn't exist anymore").Error.Contentexpression to the newHasResponseError/cast pattern, so a Ctrl-F for "Content" doesn't lead a migrating user to the fix.Proposed documentation changes
var body = response.Error.Content;response.HasResponseError(out var e)→e.Content(and mention the(Error as ApiException)?.Contentshorthand).response.Error.Contentno longer compiles after upgrading to v12") pointing atHasResponseError.Out of scope
No runtime/API change. If a future ergonomic helper is desired (e.g. a convenience accessor for response content on
IApiResponse), that should be a separateenhancementproposal, not part of this docs fix.