ErrorEventArgs.GetException Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Exception Mendapatkan yang mewakili kesalahan yang terjadi.
public:
virtual Exception ^ GetException();
public virtual Exception GetException ();
abstract member GetException : unit -> Exception
override this.GetException : unit -> Exception
Public Overridable Function GetException () As Exception
Mengembalikan
Yang Exception mewakili kesalahan yang terjadi.
Contoh
Contoh berikut membuat instans ErrorEventArgs baru dan menginisialisasinya dengan Exception. Kemudian contoh memanggil GetException untuk mengambil Exception dan menampilkan pesan kesalahan. Tidak ada formulir yang terkait dengan kode ini.
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
Berlaku untuk
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk