Skip to content

Commit

Permalink
Refactor the retrieval of inner exception into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Sep 16, 2024
1 parent 49beca2 commit d317b64
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Snowflake.Data/Core/HttpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
}
else
{
Exception innermostException = e;
while (innermostException.InnerException != null && innermostException != innermostException.InnerException)
innermostException = innermostException.InnerException;
Exception innermostException = GetInnerMostException(e);

if (innermostException is AuthenticationException)
{
Expand Down Expand Up @@ -517,6 +515,13 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
}
}

static private Exception GetInnerMostException(Exception innermostException)
{
while (innermostException.InnerException != null && innermostException != innermostException.InnerException)
innermostException = innermostException.InnerException;
return innermostException;
}

/// <summary>
/// Check whether or not the error is retryable or not.
/// </summary>
Expand Down

0 comments on commit d317b64

Please sign in to comment.