Create your own Exception class by subclassing System.Exception : Custom Exception « Development « VB.Net Tutorial






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








7.6.Custom Exception
7.6.1.Create Custom Exception class
7.6.2.Create your own Exception class by subclassing System.Exception
7.6.3.Demonstrating a user-defined exception class
7.6.4.Inherits System.ApplicationException