Catch Exception throwed from a Method : Try Catch « Development « VB.Net Tutorial






Option Strict On
 Imports System

 Class Tester

     Shared Sub Main( )
         Console.WriteLine("Enter func1...")
         Try
             Console.WriteLine("Entering Try block...")
             Func1( )
             Console.WriteLine("Exiting Try block...")
         Catch
             Console.WriteLine("Exception caught and handled")
         End Try
         Console.WriteLine("Exit func1...")
     End Sub

     Public Shared Sub Func1( )
         Console.WriteLine("Enter Func2...")
         Throw New System.Exception( )
         Console.WriteLine("Exit Func2...")
     End Sub

 End Class
Enter func1...
Entering Try block...
Enter Func2...
Exception caught and handled
Exit func1...








7.5.Try Catch
7.5.1.Try Catch Exception
7.5.2.Catch Exception throwed from a Method
7.5.3.Catch specific Exception from a Method
7.5.4.Catch different Exception with multiple catch statements
7.5.5.Filtered Exception
7.5.6.Catch without Exception type
7.5.7.Catch custom exception