Imports System.Text
Imports System.Runtime.Serialization
Imports System.Runtime.CompilerServices
Namespace System
''' <summary>
''' this Exception is not meant to be handled. Only for logging and debugging-purposes
''' </summary>
<Serializable()> _
Public Class BugException
Inherits Exception
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
End Sub
Public Sub New(ByVal message As String, ByVal innerException As Exception)
MyBase.New(message, innerException)
End Sub
End Class
Public Module BugExceptionX
' these extensions automatically add type-informations to the messages. Furthermore they concat
'°lists of anything to the message
<Extension()> _
Public Function BugException(Of T As Class)( _
ByVal sender As T, ByVal ParamArray messages As Object()) As BugException
Return New BugException(String.Concat(sender.ToString(), vbLf, String.Concat(messages)))
End Function
<Extension()> _
Public Function BugException(Of T As Class)(ByVal sender As T, ByVal innerEx As Exception, _
ByVal ParamArray messages As Object()) As BugException
Return New BugException(String.Concat( _
sender.ToString(), vbLf, String.Concat(messages)), innerEx)
End Function
End Module
End Namespace