diff --git a/Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs b/Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs index 5d81a610e..d9210c65b 100644 --- a/Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs +++ b/Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs @@ -2,6 +2,9 @@ * Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. */ +using Amazon.S3.Transfer; +using Snowflake.Data.Client; + namespace Snowflake.Data.Tests.UnitTests { using NUnit.Framework; @@ -487,15 +490,17 @@ public void TestUploadThrowsArgumentExceptionForMissingRootDirectoryWithWildcard // Set command to upload _responseData.command = CommandTypes.UPLOAD.ToString(); + _responseData.queryId = Guid.NewGuid().ToString(); _fileTransferAgent = new SFFileTransferAgent(_putQuery, _session, _responseData, _cancellationToken); // Act - Exception ex = Assert.Throws(() => _fileTransferAgent.execute()); + SnowflakeDbException ex = Assert.Throws(() => _fileTransferAgent.execute()); // Assert + Assert.AreEqual(_responseData.queryId, ex.QueryId); Assert.That(ex.Message, Does.Match($"No file found for: {tempUploadRootDirectory}\\*/{tempUploadSecondDirectory}\\*/{mockFileName}")); for (int i = 0; i < numberOfDirectories; i++) @@ -579,17 +584,21 @@ public void TestDownloadThrowsErrorFileNotFound() // Set command to download _responseData.command = CommandTypes.DOWNLOAD.ToString(); + _responseData.queryId = Guid.NewGuid().ToString(); _fileTransferAgent = new SFFileTransferAgent(GetQuery, _session, _responseData, _cancellationToken); // Act - Exception ex = Assert.Throws(() => _fileTransferAgent.execute()); + SnowflakeDbException ex = Assert.Throws(() => _fileTransferAgent.execute()); // Assert - Assert.IsInstanceOf(ex.InnerException); - Assert.That(ex.InnerException.Message, Does.Match("Could not find file .*")); + Assert.AreEqual(_responseData.queryId, ex.QueryId); + Assert.IsInstanceOf(ex.InnerException); + var innerException = ((AggregateException)ex.InnerException)?.InnerExceptions[0]; + Assert.IsInstanceOf(innerException); + Assert.That(innerException?.Message, Does.Match("Could not find file .*")); } [Test] @@ -606,17 +615,21 @@ public void TestDownloadThrowsErrorDirectoryNotFound() // Set command to download _responseData.command = CommandTypes.DOWNLOAD.ToString(); + _responseData.queryId = Guid.NewGuid().ToString(); _fileTransferAgent = new SFFileTransferAgent(GetQuery, _session, _responseData, _cancellationToken); // Act - Exception ex = Assert.Throws(() => _fileTransferAgent.execute()); + SnowflakeDbException ex = Assert.Throws(() => _fileTransferAgent.execute()); // Assert - Assert.IsInstanceOf(ex.InnerException); - Assert.That(ex.InnerException.Message, Does.Match("Could not find a part of the path .*")); + Assert.AreEqual(_responseData.queryId, ex.QueryId); + Assert.IsInstanceOf(ex.InnerException); + var innerException = ((AggregateException)ex.InnerException)?.InnerExceptions[0]; + Assert.IsInstanceOf(innerException); + Assert.That(innerException?.Message, Does.Match("Could not find a part of the path .*")); } } } diff --git a/Snowflake.Data/Client/SnowflakeDbException.cs b/Snowflake.Data/Client/SnowflakeDbException.cs index c75929390..f61349762 100755 --- a/Snowflake.Data/Client/SnowflakeDbException.cs +++ b/Snowflake.Data/Client/SnowflakeDbException.cs @@ -46,7 +46,7 @@ public SnowflakeDbException(string sqlState, int vendorCode, string errorMessage } public SnowflakeDbException(SFError error, string queryId, Exception innerException) - : base(FormatExceptionMessage(error, new object[] {innerException.Message}, string.Empty, queryId)) + : base(FormatExceptionMessage(error, new object[] {innerException.Message}, string.Empty, queryId), innerException) { VendorCode = error.GetAttribute().errorCode; QueryId = queryId; diff --git a/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs b/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs index 909a0f4ce..45d55f137 100644 --- a/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs +++ b/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs @@ -228,16 +228,6 @@ public void execute() download(); } } - catch (FileNotFoundException e) - { - Logger.Error("File not found while transferring file(s): " + e.Message); - throw new SnowflakeDbException(SFError.IO_ERROR_ON_GETPUT_COMMAND, TransferMetadata.queryId, e); - } - catch (IOException e) - { - Logger.Error("IO operation error while transferring file(s): " + e.Message); - throw new SnowflakeDbException(SFError.IO_ERROR_ON_GETPUT_COMMAND, TransferMetadata.queryId, e); - } catch (Exception e) { Logger.Error("Error while transferring file(s): " + e.Message);