jj: try to fix unhandled exception

This commit is contained in:
Jonathan Jenne
2018-06-29 12:58:47 +02:00
parent bf43248270
commit 88feb253d1
3 changed files with 173 additions and 64 deletions

View File

@@ -40,9 +40,17 @@ Public Class ClassDatabase
Return dt
Catch ex As SqlException
CatchDatabaseTimeout(ex, sql_command)
Dim handled = CatchDatabaseTimeout(ex, sql_command)
Return Nothing
If Not handled Then
If userInput = True Then
MsgBox("Error in Return_Datatable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
End If
ClassLogger.Add("Unexpected error in Return_Datatable: " & ex.Message, True)
ClassLogger.Add("#SQL: " & sql_command, False)
End If
Return False
Catch ex As Exception
If userInput = True Then
MsgBox("Error in Return Datatable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
@@ -71,9 +79,17 @@ Public Class ClassDatabase
Return dt
Catch ex As SqlException
CatchDatabaseTimeout(ex, sql_command)
Dim handled = CatchDatabaseTimeout(ex, sql_command)
Return Nothing
If Not handled Then
If userInput = True Then
MsgBox("Error in Return_Datatable_CS - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
End If
ClassLogger.Add("Unexpected error in Return_Datatable_CS: " & ex.Message, True)
ClassLogger.Add("#SQL: " & sql_command, False)
End If
Return False
Catch ex As Exception
If userInput = True Then
MsgBox("Error in Return_Datatable_CS - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
@@ -101,9 +117,17 @@ Public Class ClassDatabase
Return True
Catch ex As SqlException
CatchDatabaseTimeout(ex, sql_command)
Dim handled = CatchDatabaseTimeout(ex, sql_command)
Return Nothing
If Not handled Then
If userInput = True Then
MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
End If
ClassLogger.Add("Unexpected error in Execute_non_Query: " & ex.Message, True)
ClassLogger.Add("#SQL: " & sql_command, False)
End If
Return False
Catch ex As Exception
If userInput = True Then
MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
@@ -133,9 +157,17 @@ Public Class ClassDatabase
Return result
Catch ex As SqlException
CatchDatabaseTimeout(ex, sql_command)
Dim handled = CatchDatabaseTimeout(ex, sql_command)
Return Nothing
If Not handled Then
If userInput = True Then
MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
End If
ClassLogger.Add("Unexpected error in Execute_non_Query: " & ex.Message, True)
ClassLogger.Add("#SQL: " & sql_command, False)
End If
Return False
Catch ex As Exception
If userInput = True Then
MsgBox("Error in Execute Scalar - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical)
@@ -213,7 +245,7 @@ Public Class ClassDatabase
End Try
End Function
Public Shared Sub CatchDatabaseTimeout(ex As SqlException, sql_command As String)
Public Shared Function CatchDatabaseTimeout(ex As SqlException, sql_command As String)
Dim FatalErrors As New List(Of Integer) From {-1, -2, 121}
If FatalErrors.Contains(ex.Number) Then
@@ -221,6 +253,10 @@ Public Class ClassDatabase
ClassLogger.Add("Network timeout error in Return_Datatable: " & ex.Message, True)
ClassLogger.Add("#SQL: " & sql_command, False)
Return True
Else
Return False
End If
End Sub
End Function
End Class