Use FormHelper to show error messages

This commit is contained in:
Jonathan Jenne
2021-11-01 10:45:53 +01:00
parent b157fc0c2b
commit 0562d9c37d
2 changed files with 20 additions and 26 deletions

View File

@@ -1,16 +1,20 @@
Imports DigitalData.Modules.Logging
Public Class Message
Private Logger As Logger
Public Class FormHelper
Private ReadOnly Logger As Logger
Public Sub New(pLogConfig As LogConfig)
Logger = pLogConfig.GetLogger()
End Sub
Public Sub [Error](pException As Exception, pMessage As String)
Public Sub ShowError(pException As Exception, pFunction As String, Optional pDetails As String = "")
Dim oMessage = String.Format(My.Resources.frmShared.In_der_Funktion___0___ist_folgender_Fehler_aufgetreten___1_, pFunction, vbNewLine & vbNewLine & pException.Message)
If pDetails <> String.Empty Then
oMessage &= $"{vbNewLine}{pDetails}"
End If
Logger.Error(pException)
Dim oMessage As String = $"{pMessage}{vbNewLine}{vbNewLine}{pException.Message}"
MsgBox(oMessage, MsgBoxStyle.Critical, "Schwerwiegender Fehler")
MsgBox(oMessage, MsgBoxStyle.Critical, Application.ProductName)
End Sub
End Class