ErrorEventArgs.GetException 메서드

정의

발생한 오류를 나타내는 Exception을 가져옵니다.Gets the Exception that represents the error that occurred.

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입니다.An Exception that represents the error that occurred.

예제

다음 예제에서는의 새 인스턴스를 만들고를 ErrorEventArgs 사용 하 여이를 초기화 Exception 합니다.The following example creates a new instance of ErrorEventArgs and initializes it with an Exception. 그런 다음를 호출 GetException 하 여를 검색 하 Exception 고 오류 메시지를 표시 합니다.Then the example calls GetException to retrieve the Exception and display the error message. 이 코드와 연결 된 폼이 없습니다.There is no form associated with this code.

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

적용 대상