Add ErrorHandler Class
This commit is contained in:
29
EDMI_ClientSuite/ClassErrorHandler.vb
Normal file
29
EDMI_ClientSuite/ClassErrorHandler.vb
Normal file
@@ -0,0 +1,29 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ClassErrorHandler
|
||||
Private _Logger As Logger
|
||||
|
||||
Public Sub New(Logger As Logger)
|
||||
_Logger = Logger
|
||||
End Sub
|
||||
|
||||
Private Function GetMessage(Exception As Exception)
|
||||
Dim oTargetSite = Exception.TargetSite
|
||||
Dim oMethodName = oTargetSite.ReflectedType.Name
|
||||
Dim oFormName = oTargetSite.ReflectedType.ReflectedType.Name
|
||||
Dim oMessage As String = String.Empty
|
||||
|
||||
oMessage &= $"Form: {oFormName}{vbNewLine}"
|
||||
oMessage &= $"Method: {oMethodName}{vbNewLine}"
|
||||
oMessage &= $"{Exception.Message}{vbNewLine}{Exception.StackTrace}{vbNewLine}{vbNewLine}"
|
||||
oMessage &= $"Please report this error to error@digitaldata.works"
|
||||
|
||||
Return oMessage
|
||||
End Function
|
||||
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
_Logger.Error(Exception)
|
||||
MsgBox(GetMessage(Exception), MsgBoxStyle.Critical, "Unexpected Error")
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user