From 9133cc1601ccf4ae84e84740c246d1a6a3108098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Hofman?= Date: Tue, 30 Jan 2024 15:58:10 +0100 Subject: [PATCH] Github warning fixes, removal of some other warnings related to rethrowing exceptions --- Snowflake.Data/Client/SnowflakeDbException.cs | 11 ++++++----- .../Core/FileTransfer/SFFileTransferAgent.cs | 12 ++++++++---- Snowflake.Data/Core/SFBindUploader.cs | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Snowflake.Data/Client/SnowflakeDbException.cs b/Snowflake.Data/Client/SnowflakeDbException.cs index f61349762..9b9f0e0a9 100755 --- a/Snowflake.Data/Client/SnowflakeDbException.cs +++ b/Snowflake.Data/Client/SnowflakeDbException.cs @@ -23,8 +23,9 @@ public sealed class SnowflakeDbException : DbException static private ResourceManager rm = new ResourceManager("Snowflake.Data.Core.ErrorMessages", typeof(SnowflakeDbException).Assembly); - public string SqlState { get; private set; } - + private string _sqlState; + public override string SqlState => _sqlState; + private int VendorCode; public string QueryId { get; set; } @@ -40,7 +41,7 @@ public override int ErrorCode public SnowflakeDbException(string sqlState, int vendorCode, string errorMessage, string queryId) : base(FormatExceptionMessage(errorMessage, vendorCode, sqlState, queryId)) { - SqlState = sqlState; + _sqlState = sqlState; VendorCode = vendorCode; QueryId = queryId; } @@ -62,7 +63,7 @@ public SnowflakeDbException(string sqlState, SFError error, params object[] args : base(FormatExceptionMessage(error, args, sqlState, string.Empty)) { VendorCode = error.GetAttribute().errorCode; - SqlState = sqlState; + _sqlState = sqlState; } public SnowflakeDbException(Exception innerException, SFError error, params object[] args) @@ -75,7 +76,7 @@ public SnowflakeDbException(Exception innerException, string sqlState, SFError e : base(FormatExceptionMessage(error, args, sqlState, string.Empty), innerException) { VendorCode = error.GetAttribute().errorCode; - SqlState = sqlState; + _sqlState = sqlState; } static string FormatExceptionMessage(SFError error, diff --git a/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs b/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs index 1932b7079..b27daa51f 100644 --- a/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs +++ b/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs @@ -709,8 +709,9 @@ private int GetFileTransferMaxBytesInMemory() { return int.Parse(maxBytesInMemoryString); } - catch (Exception e) + catch (Exception) { + Logger.Warn("Default for FILE_TRANSFER_MEMORY_THRESHOLD used due to invalid session value."); return FileTransferConfiguration.DefaultMaxBytesInMemory; } } @@ -1278,7 +1279,8 @@ private async Task UploadSingleFileAsync( } catch (Exception ex) { - throw ex; + Logger.Error("UploadSingleFileAsync encountered an error: " + ex.Message); + throw; } finally { @@ -1315,7 +1317,8 @@ private SFFileMetadata DownloadSingleFile( } catch (Exception ex) { - throw ex; + Logger.Error("DownloadSingleFile encountered an error: " + ex.Message); + throw; } finally { @@ -1352,7 +1355,8 @@ private async Task DownloadSingleFileAsync( } catch (Exception ex) { - throw ex; + Logger.Error("DownloadSingleFileAsync encountered an error: " + ex.Message); + throw; } finally { diff --git a/Snowflake.Data/Core/SFBindUploader.cs b/Snowflake.Data/Core/SFBindUploader.cs index 56cd376bd..68af7405b 100644 --- a/Snowflake.Data/Core/SFBindUploader.cs +++ b/Snowflake.Data/Core/SFBindUploader.cs @@ -297,7 +297,7 @@ private void CreateStage() { session.SetArrayBindStageThreshold(0); logger.Error("Failed to create temporary stage for array binds.", e); - throw e; + throw; } } } @@ -321,7 +321,7 @@ internal async Task CreateStageAsync(CancellationToken cancellationToken) { session.SetArrayBindStageThreshold(0); logger.Error("Failed to create temporary stage for array binds.", e); - throw e; + throw; } } }