MultiTool/MultiTool.Form/FormHelpers.vb
Jonathan Jenne cc49d821f3 WIP
2021-11-12 16:43:16 +01:00

31 lines
1.0 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
End Class