Inner Exception Demo : Exception Stack « Development « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
VB.Net » Development » Exception StackScreenshots 
Inner Exception Demo
Inner Exception Demo

Imports System
Imports System.Text
Imports System.Text.RegularExpressions


Public Class MainClass
         Shared Sub Main(  )
             Try
                 DangerousFunc1(  )

             Catch As MyCustomException
                 Console.WriteLine(ControlChars.Lf + "{0}", e.Message)
                 Console.WriteLine("Retrieving exception history...")
                 Dim inner As Exception = e.InnerException
                 While Not (inner Is Nothing)
                     Console.WriteLine("{0}", inner.Message)
                     inner = inner.InnerException
                 End While
             End Try
         End Sub 'Main

         Shared Public Sub DangerousFunc1(  )
             Try
                 DangerousFunc2(  )
             Catch As System.Exception
                 Dim ex As New MyCustomException_
                  "E3 - Custom Exception Situation!", e)
                 Throw ex
             End Try
         End Sub

         Shared Public Sub DangerousFunc2(  )
             Try
                 DangerousFunc3(  )
             Catch As System.DivideByZeroException
                 Dim ex As New Exception_
                     "E2 - Func2 caught divide by zero", e)
                 Throw ex
             End Try
         End Sub 'DangerousFunc2

         Shared Public Sub DangerousFunc3(  )
             Try
                 DangerousFunc4(  )
             Catch As System.ArithmeticException
                 Throw e

             Catch As System.Exception
                 Console.WriteLine("Exception handled here!")

             End Try
         End Sub 'DangerousFunc3

         Shared Public Sub DangerousFunc4(  )
             Throw New DivideByZeroException("E1 - DivideByZero Exception")
         End Sub
   
End Class

     Public Class MyCustomException
         Inherits System.ApplicationException

         Public Sub New(ByVal message As String, ByVal inner As Exception)
             MyBase.New(message, inner)
         End Sub 'New
     End Class 'MyCustomException

           
       
Related examples in the same category
1. Display Exception Stack TraceDisplay Exception Stack Trace
w___w__w._j__a___v__a2_s___.___co___m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.