improve documentresultlist
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
Imports System.Reflection
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ClassErrorHandler
|
||||
Private _Logger As Logger
|
||||
|
||||
Private Const UNKNOWN_METHOD = "Unknown Method"
|
||||
Private Const UNKNOWN_FORM = "Unknown Form"
|
||||
|
||||
Public Sub New(Logger As Logger)
|
||||
_Logger = Logger
|
||||
End Sub
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
_Logger.Error(Exception)
|
||||
MsgBox(GetMessage(Exception), MsgBoxStyle.Critical, "Unexpected Error")
|
||||
End Sub
|
||||
|
||||
Private Function GetMessage(Exception As Exception) As String
|
||||
Dim oTargetSite = Exception.TargetSite
|
||||
Dim oMethodName = GetMethodName(Exception)
|
||||
Dim oFormName = GetFormName(Exception)
|
||||
Dim oMessage As String = String.Empty
|
||||
|
||||
oMessage &= $"Form: {oFormName}{vbNewLine}"
|
||||
oMessage &= $"Method: {oMethodName}{vbNewLine}"
|
||||
|
||||
If Not String.IsNullOrEmpty(Exception.StackTrace) Then
|
||||
oMessage &= $"Message: {Exception.Message}{vbNewLine}{vbNewLine}"
|
||||
End If
|
||||
|
||||
If Not String.IsNullOrEmpty(Exception.StackTrace) Then
|
||||
oMessage &= $"Stacktrace: {Exception.StackTrace}{vbNewLine}"
|
||||
End If
|
||||
|
||||
oMessage &= $"{vbNewLine}"
|
||||
oMessage &= $"Please report this error to error@digitaldata.works"
|
||||
|
||||
Return oMessage
|
||||
End Function
|
||||
|
||||
Private Function GetMethodName(Exception As Exception) As String
|
||||
Dim oMethodName = Exception.TargetSite?.ReflectedType?.Name
|
||||
|
||||
If oMethodName Is Nothing Then
|
||||
Return UNKNOWN_METHOD
|
||||
Else
|
||||
Return oMethodName
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function GetFormName(Exception As Exception) As String
|
||||
Dim oFormName = Exception.TargetSite?.ReflectedType?.ReflectedType?.Name
|
||||
|
||||
If oFormName Is Nothing Then
|
||||
Return UNKNOWN_FORM
|
||||
Else
|
||||
Return oFormName
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
@@ -97,7 +97,6 @@
|
||||
<Compile Include="Config\ClassConfig.vb" />
|
||||
<Compile Include="ClassConstants.vb" />
|
||||
<Compile Include="ClassEnvironment.vb" />
|
||||
<Compile Include="ClassErrorHandler.vb" />
|
||||
<Compile Include="ClassFlowForm.vb" />
|
||||
<Compile Include="ClassInitLoader.vb" />
|
||||
<Compile Include="Config\ClassUIConfig.vb" />
|
||||
|
||||
Reference in New Issue
Block a user