Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Follow up fix
  • Loading branch information
alexeyzimarev committed Nov 19, 2025
commit bed88f553bc5f76a154ee3ff93e55a2fa5f51775
2 changes: 1 addition & 1 deletion src/RestSharp/Response/RestResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async Task<RestResponse> GetDefaultResponse() {
ContentLength = httpResponse.Content?.Headers.ContentLength,
ContentType = httpResponse.Content?.Headers.ContentType?.MediaType,
Cookies = cookieCollection,
ErrorException = httpResponse.MaybeException(options.ErrorWhenUnsuccessfulStatusCode),
ErrorException = httpResponse.MaybeException(options.SetErrorExceptionOnUnsuccessfulStatusCode),
Headers = httpResponse.Headers.GetHeaderParameters(),
IsSuccessStatusCode = httpResponse.IsSuccessStatusCode,
RawBytes = bytes,
Expand Down
2 changes: 1 addition & 1 deletion src/RestSharp/RestClient.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<RestResponse> ExecuteAsync(RestRequest request, CancellationTo
request.CompletionOption = HttpCompletionOption.ResponseHeadersRead;
var response = await ExecuteRequestAsync(request, cancellationToken).ConfigureAwait(false);

var exception = response.Exception ?? response.ResponseMessage?.MaybeException(Options.ErrorWhenUnsuccessfulStatusCode);
var exception = response.Exception ?? response.ResponseMessage?.MaybeException(Options.SetErrorExceptionOnUnsuccessfulStatusCode);

if (exception != null) {
return Options.ThrowOnAnyError ? throw exception : null;
Expand Down
2 changes: 1 addition & 1 deletion test/RestSharp.Tests.Integrated/RequestFailureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task Handles_GET_Request_Errors_With_Response_Type() {

[Fact]
public async Task Does_not_throw_on_unsuccessful_status_code_with_option() {
using var client = new RestClient(new RestClientOptions(server.Url!) { ErrorWhenUnsuccessfulStatusCode = false });
using var client = new RestClient(new RestClientOptions(server.Url!) { SetErrorExceptionOnUnsuccessfulStatusCode = false });
var request = new RestRequest("status?code=404");
var response = await client.ExecuteAsync<SuccessResponse>(request);

Expand Down
Loading