Common: Improve BaseForms and ErrorHandler
This commit is contained in:
@@ -14,9 +14,14 @@ Namespace Base
|
||||
_Form = Form
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
Public Sub ShowErrorMessage(Exception As Exception, Origin As String)
|
||||
Dim oMessage = GetMessage(Exception, Origin)
|
||||
ShowErrorMessage(Exception, Origin, oMessage)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception, Origin As String, Message As String)
|
||||
_Logger.Error(Exception)
|
||||
MessageBox.Show(GetMessage(Exception), _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
MessageBox.Show(Message, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowInfoMessage(Text As String)
|
||||
@@ -24,8 +29,7 @@ Namespace Base
|
||||
MessageBox.Show(Text, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
End Sub
|
||||
|
||||
Private Function GetMessage(Exception As Exception) As String
|
||||
Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2)
|
||||
Private Function GetMessage(Exception As Exception, Origin As String) As String
|
||||
Dim oMessage As String = String.Empty
|
||||
|
||||
If TypeOf Exception Is SqlClient.SqlException Then
|
||||
@@ -37,13 +41,13 @@ Namespace Base
|
||||
ElseIf TypeOf Exception Is NoNullAllowedException Then
|
||||
oMessage = "Einige benötigte Felder wurde nicht ausgefüllt."
|
||||
Else
|
||||
oMessage = $"Es ist ein unerwarteter Fehler in {oCallingClass} aufgetreten. Mehr Informationen finden Sie im Log."
|
||||
oMessage = $"An unhandled exception occurred in {Origin}: " & vbNewLine &
|
||||
Exception.Message & vbNewLine & vbNewLine &
|
||||
"More information can be found in the Application Log."
|
||||
End If
|
||||
|
||||
If _LogConfig.Debug Then
|
||||
oMessage &= vbNewLine & vbNewLine & "== Debug Informationen =="
|
||||
oMessage &= vbNewLine & vbNewLine & "Die ursprüngliche Fehlermeldung lautet:"
|
||||
oMessage &= vbNewLine & Exception.Message
|
||||
oMessage &= vbNewLine & vbNewLine & "=== Debug Information ==="
|
||||
oMessage &= vbNewLine & vbNewLine & "Stacktrace:"
|
||||
oMessage &= vbNewLine & Exception.StackTrace
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user