i have about 20 possible exception messages that i want thrown when an error occurs. i need somthng like this when catching the exception
Try
' do domthing
Catch ex As CustomInvalidArgumentException
'do domthing
Catch ex As CustomUnexcpectedException
'do domthing
Catch ex As Exception
'do domthing
End Try
currently i have a class like this
<Serializable()> _
Public Class CustomException
Inherits Exception
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
Public Sub New(ByVal format As String, ByVal ParamArray args As Object())
MyBase.New(String.Format(format, args))
End Sub
Public Sub New(ByVal message As String, ByVal innerException As Exception)
MyBase.New(message, innerException)
End Sub
Public Sub New(ByVal format As String, ByVal innerException As Exception, ByVal ParamArray args As Object())
MyBase.New(String.Format(format, args), innerException)
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
End Sub
End Class
do i have to create a class that inherits from Exception for each type of exception