41 lines
1.4 KiB
VB.net
41 lines
1.4 KiB
VB.net
Imports DigitalData.Modules.Logging
|
|
Imports MultiTool.Shared.Exceptions
|
|
|
|
Public Class FormHelper
|
|
Private ReadOnly Logger As Logger
|
|
|
|
Public Sub New(pLogConfig As LogConfig)
|
|
Logger = pLogConfig.GetLogger()
|
|
End Sub
|
|
|
|
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
|
|
|
|
If TypeOf pException Is MultiToolException Then
|
|
oMessage &= $"{vbNewLine}"
|
|
|
|
Select Case pException.GetType()
|
|
Case GetType(MissingAttributeException)
|
|
oMessage &= $"Fehlendes Attribut: '{pException.Message}'"
|
|
End Select
|
|
End If
|
|
|
|
Logger.Error(pException)
|
|
MsgBox(oMessage, MsgBoxStyle.Critical, Application.ProductName)
|
|
End Sub
|
|
|
|
Public Sub ShowWarning(pMessage As String, Optional pDetails As String = "")
|
|
Dim oMessage As String = pMessage
|
|
If pDetails <> String.Empty Then
|
|
oMessage &= $"{vbNewLine}{pDetails}"
|
|
End If
|
|
|
|
Logger.Info(oMessage)
|
|
MsgBox(oMessage, MsgBoxStyle.Exclamation, Application.ProductName)
|
|
End Sub
|
|
|
|
End Class
|