Skip to content

Commit

Permalink
SNOW-902611 bugfixes for open failures
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mhofman committed Oct 6, 2023
1 parent 3642b96 commit 52d4038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 11 additions & 2 deletions Snowflake.Data/Client/SnowflakeDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,18 @@ public override void Open()
}
catch (Exception e)
{
// Otherwise when Dispose() is called, the close request would timeout.
_connectionState = ConnectionState.Closed;
logger.Error(e.Message);
throw;
logger.Error("Unable to connect: ", e);
if (e is SnowflakeDbException)
{
throw;
}
throw new SnowflakeDbException(
e,
SnowflakeDbException.CONNECTION_FAILURE_SSTATE,
SFError.INTERNAL_ERROR,
"Unable to connect. " + e.Message);
}
}

Expand Down
7 changes: 2 additions & 5 deletions Snowflake.Data/Core/Session/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,17 @@ internal Task<SFSession> NewSessionAsync(String connectionString, SecureString p
.OpenAsync(cancellationToken)
.ContinueWith(previousTask =>
{
if (previousTask.IsCanceled)
cancellationToken.ThrowIfCancellationRequested();

if (previousTask.IsFaulted && previousTask.Exception != null)
throw previousTask.Exception;

if (previousTask.IsFaulted)
throw new SnowflakeDbException(
SnowflakeDbException.CONNECTION_FAILURE_SSTATE,
SFError.INTERNAL_ERROR,
"Async open on connection failure");
"Failure while opening session async");

return session;
}, cancellationToken);
}, TaskContinuationOptions.NotOnCanceled);
}
catch (Exception e)
{
Expand Down

0 comments on commit 52d4038

Please sign in to comment.