Skip to content

Commit

Permalink
catch exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Davoud Eshtehari authored and Davoud Eshtehari committed Sep 30, 2020
1 parent 81a0026 commit 64a50c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -331,6 +331,11 @@ public override uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = nul
packet.WriteToStreamAsync(_stream, cb, SNIProviders.NP_PROV);
return TdsEnums.SNI_SUCCESS_IO_PENDING;
}
catch (Exception e) when (e is ObjectDisposedException || e is InvalidOperationException || e is IOException)
{
SNIPacket errorPacket = packet;
return ReportErrorAndReleasePacket(errorPacket, e);
}
finally
{
SqlClientEventSource.Log.TrySNIScopeLeaveEvent(scopeID);
Expand Down
Expand Up @@ -707,7 +707,6 @@ public override void SetAsyncCallbacks(SNIAsyncCallback receiveCallback, SNIAsyn
public override uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = null)
{
long scopeID = SqlClientEventSource.Log.TrySNIScopeEnterEvent("<sc.SNI.SNITcpHandle.SendAsync |SNI|SCOPE>");
SNIPacket errorPacket;
SNIAsyncCallback cb = callback ?? _sendCallback;
try
{
Expand All @@ -716,7 +715,7 @@ public override uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = nul
}
catch (Exception e) when (e is ObjectDisposedException || e is InvalidOperationException || e is IOException)
{
errorPacket = packet;
SNIPacket errorPacket = packet;
return ReportErrorAndReleasePacket(errorPacket, e);
}
finally
Expand Down

0 comments on commit 64a50c5

Please sign in to comment.