Skip to content

Commit

Permalink
fix: properly re-throw caught exception in eager connection code (#550)
Browse files Browse the repository at this point in the history
To preserve the original stack trace, one needs to use a throw;
statement, not re-throw the original exception. See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/exception-handling-statements
  • Loading branch information
malandis authored Mar 18, 2024
1 parent aa9742e commit c1ce272
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Momento.Sdk/CacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public static async Task<ICacheClient> CreateAsync(IConfiguration config, ICrede
{
await cacheClient.DataClient.EagerConnectAsync(eagerConnectionTimeout);
}
catch (Exception e)
catch (Exception)
{
cacheClient.Dispose();
throw e;
throw;
}
return cacheClient;
}
Expand Down

0 comments on commit c1ce272

Please sign in to comment.