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

fix: throw error if ThrowOnAnyError flag is true #1515

Merged
merged 1 commit into from Oct 23, 2020
Merged

fix: throw error if ThrowOnAnyError flag is true #1515

merged 1 commit into from Oct 23, 2020

Conversation

FrediKats
Copy link
Contributor

@FrediKats FrediKats commented Oct 10, 2020

Description

fix #1511

RestClient property ThrowOnAnyError is not work correct becouse all exceptions are handled before this check:

try
{
    var http = ConfigureHttp(request);
                
    request.OnBeforeRequest?.Invoke(http);

    response = RestResponse.FromHttpResponse(getResponse(http, httpMethod), request);
}
catch (Exception ex)
{
    if (ThrowOnAnyError) throw;
                
    response.ResponseStatus = ResponseStatus.Error;
    response.ErrorMessage   = ex.Message;
    response.ErrorException = ex;
}

In getResponse we have:

catch (Exception ex)
{
    return ExtractErrorResponse(ex);
}

Purpose

This pull request is a:

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@alexeyzimarev alexeyzimarev merged commit 6e10429 into restsharp:dev Oct 23, 2020
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ThrowOnAnyError does not throw
2 participants