Mega Code Archive

 
Categories / VB.Net Tutorial / Development
 

Create your own Exception class by subclassing System Exception

Imports System.Runtime.Serialization Public Class CustomException    Inherits System.Exception    Public Sub New()       Me.New("An error occurred in the component.", Nothing)    End Sub    Public Sub New(message As String)       Me.New(message, Nothing)    End Sub    Public Sub New(message As String, innerException As Exception)       MyBase.New(message, innerException)       Source = "My_Custom_Component"    End Sub    Protected Sub New(info As SerializationInfo, context As StreamingContext)       MyBase.New(info, context)    End Sub End Class