Skip to content

Commit

Permalink
SNOW-950923 ensuring any exception throw during file transfer provide…
Browse files Browse the repository at this point in the history
…s queryid
  • Loading branch information
sfc-gh-mhofman committed Dec 6, 2023
1 parent 6ca9c91 commit b9661c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Snowflake.Data/Client/SnowflakeDbException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public sealed class SnowflakeDbException : DbException

private int VendorCode;

public string QueryId { get; }
public string QueryId { get; set; }

public override int ErrorCode
{
Expand Down
13 changes: 13 additions & 0 deletions Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ public void execute()
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);
if (e is SnowflakeDbException snowflakeException)
{
if (snowflakeException.QueryId == null)
{
snowflakeException.QueryId = TransferMetadata.queryId;
}
throw snowflakeException;
}
throw new SnowflakeDbException(SFError.IO_ERROR_ON_GETPUT_COMMAND, TransferMetadata.queryId, e);
}

}

Expand Down
3 changes: 1 addition & 2 deletions Snowflake.Data/Core/SFStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ internal SFBaseResultSet Execute(int timeout, string sql, Dictionary<string, Bin
bindings,
describeOnly);

if (logger.IsDebugEnabled())
logger.Debug("PUT/GET queryId: " + (response.data != null ? response.data.queryId : "Unknown"));
logger.Debug("PUT/GET queryId: " + (response.data != null ? response.data.queryId : "Unknown"));

SFFileTransferAgent fileTransferAgent =
new SFFileTransferAgent(trimmedSql, SfSession, response.data, CancellationToken.None);
Expand Down

0 comments on commit b9661c9

Please sign in to comment.