30 lines
969 B
VB.net
30 lines
969 B
VB.net
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
|