ErrorEventArgs.GetException メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
発生したエラーを表す Exception を取得します。
public:
virtual Exception ^ GetException();
public virtual Exception GetException();
abstract member GetException : unit -> Exception
override this.GetException : unit -> Exception
Public Overridable Function GetException () As Exception
返品
発生したエラーを表す Exception 。
例
次の例では、 ErrorEventArgs の新しいインスタンスを作成し、 Exceptionで初期化します。 次に、 GetException を呼び出して Exception を取得し、エラー メッセージを表示します。 このコードに関連付けられているフォームはありません。
public static void Main(string[] args) {
//Creates an exception with an error message.
Exception myException= new Exception("This is an exception test");
//Creates an ErrorEventArgs with the exception.
ErrorEventArgs myErrorEventArgs = new ErrorEventArgs(myException);
//Extracts the exception from the ErrorEventArgs and display it.
Exception myReturnedException = myErrorEventArgs.GetException();
MessageBox.Show("The returned exception is: " + myReturnedException.Message);
}
Public Shared Sub Main()
'Creates an exception with an error message.
Dim myException As New Exception("This is an exception test")
'Creates an ErrorEventArgs with the exception.
Dim myErrorEventArgs As New ErrorEventArgs(myException)
'Extracts the exception from the ErrorEventArgs and display it.
Dim myReturnedException As Exception = myErrorEventArgs.GetException()
MessageBox.Show("The returned exception is: " _
+ myReturnedException.Message)
End Sub