ErrorEventArgs.GetException 메서드

정의

발생한 오류를 나타내는 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

발생한 오류를 나타내는 Exception입니다.

예제

다음 예제에서는 새 인스턴스를 ErrorEventArgs 만들고 .을 사용하여 Exception초기화합니다. 그런 다음 예제에서는 오류 메시지를 검색 Exception 하고 표시하기 위해 호출 GetException 합니다. 이 코드와 연결된 양식이 없습니다.

int main()
{
   
   //Creates an exception with an error message.
   Exception^ myException = gcnew Exception( "This is an exception test" );
   
   //Creates an ErrorEventArgs with the exception.
   ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException );
   
   //Extracts the exception from the ErrorEventArgs and display it.
   Exception^ myReturnedException = myErrorEventArgs->GetException();
   MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) );
}

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

적용 대상