本文整理匯總了VB.NET中System.Exception.InnerException屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Exception.InnerException屬性的具體用法?VB.NET Exception.InnerException怎麽用?VB.NET Exception.InnerException使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Exception
的用法示例。
在下文中一共展示了Exception.InnerException屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Public Class AppException : Inherits Exception
Public Sub New(message As String)
MyBase.New(message)
End Sub
Public Sub New(message As String, inner As Exception)
MyBase.New(message, inner)
End Sub
End Class
Public Class Example
Public Shared Sub Main()
Dim testInstance As New Example()
Try
testInstance.CatchInner()
Catch e As AppException
Console.WriteLine ("In catch block of Main method.")
Console.WriteLine("Caught: {0}", e.Message)
If e.InnerException IsNot Nothing Then
Console.WriteLine("Inner exception: {0}", e.InnerException)
End If
End Try
End Sub
Public Sub ThrowInner()
Throw New AppException("Exception in ThrowInner method.")
End Sub
Public Sub CatchInner()
Try
Me.ThrowInner()
Catch e As AppException
Throw New AppException("Error in CatchInner caused by calling the ThrowInner method.", e)
End Try
End Sub
End Class
輸出:
In catch block of Main method. Caught: Error in CatchInner caused by calling the ThrowInner method. Inner exception: AppException: Exception in ThrowInner method. at Example.CatchInner()