Skip to content

Commit

Permalink
Log exceptions when operating with token cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Dec 13, 2024
1 parent ef7b2ee commit f5e1862
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public string GetCredentials(string key)
}
}
}
catch (Exception exception)
{
s_logger.Error("Failed to get credentials", exception);
throw;

Check warning on line 142 in Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs#L139-L142

Added lines #L139 - L142 were not covered by tests
}
finally
{
ReleaseLock();
Expand Down Expand Up @@ -166,6 +171,11 @@ public void RemoveCredentials(string key)
WriteToJsonFile(JsonConvert.SerializeObject(credentials));
}
}
catch (Exception exception)
{
s_logger.Error("Failed to remove credentials", exception);
throw;

Check warning on line 177 in Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerFileImpl.cs#L174-L177

Added lines #L174 - L177 were not covered by tests
}
finally
{
ReleaseLock();
Expand All @@ -192,6 +202,11 @@ public void SaveCredentials(string key, string token)
string jsonString = JsonConvert.SerializeObject(credentials);
WriteToJsonFile(jsonString);
}
catch (Exception exception)
{
s_logger.Error("Failed to save credentials", exception);
throw;
}
finally
{
ReleaseLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public string GetCredentials(string key)
{
success = CredRead(key, 1 /* Generic */, 0, out nCredPtr);
}
catch (Exception exception)
{
s_logger.Error($"Failed to get credentials", exception);
throw;

Check warning on line 37 in Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs#L34-L37

Added lines #L34 - L37 were not covered by tests
}
finally
{
_lock.ExitReadLock();
Expand Down Expand Up @@ -58,6 +63,11 @@ public void RemoveCredentials(string key)
{
success = CredDelete(key, 1 /* Generic */, 0);
}
catch (Exception exception)
{
s_logger.Error($"Failed to remove credentials", exception);
throw;

Check warning on line 69 in Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs#L66-L69

Added lines #L66 - L69 were not covered by tests
}
finally
{
_lock.ExitWriteLock();
Expand Down Expand Up @@ -89,6 +99,11 @@ public void SaveCredentials(string key, string token)
{
CredWrite(ref credential, 0);
}
catch (Exception exception)
{
s_logger.Error($"Failed to save credentials", exception);
throw;

Check warning on line 105 in Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/CredentialManager/Infrastructure/SFCredentialManagerWindowsNativeImpl.cs#L102-L105

Added lines #L102 - L105 were not covered by tests
}
finally
{
_lock.ExitWriteLock();
Expand Down

0 comments on commit f5e1862

Please sign in to comment.