Database: Throw when Connection is nothing in MaybeGetTransaction

This commit is contained in:
Jonathan Jenne
2021-05-17 10:39:38 +02:00
parent 4c78e6e5a7
commit d32a14c4d8
2 changed files with 19 additions and 7 deletions

View File

@@ -74,6 +74,10 @@ Public Class MSSQLServer
End Function
Private Function MaybeGetTransaction(Connection As SqlConnection, Mode As TransactionMode, Transaction As SqlTransaction) As SqlTransaction
If Connection Is Nothing Then
Throw New ArgumentNullException("Connection")
End If
If Mode = TransactionMode.NoTransaction Then
Return Nothing
ElseIf Mode = TransactionMode.ExternalTransaction Then
@@ -176,14 +180,15 @@ Public Class MSSQLServer
End Try
End Function
''' <summary>
''' This Function intentionally has no try..catch block to have any errors caught outside
''' </summary>
''' <param name="Connection"></param>
''' <returns></returns>
Private Function OpenSQLConnection(Connection As SqlConnection) As SqlConnection
Try
If Connection.State = ConnectionState.Closed Then
Connection.Open()
End If
Catch ex As Exception
_Logger.Error(ex)
End Try
If Connection.State = ConnectionState.Closed Then
Connection.Open()
End If
Return Connection
End Function