Udostępnij za pośrednictwem


CException::ReportError

Wywołanie tej funkcji Członkowskich tekst raportu o błędzie w polu wiadomość do użytkownika.

virtual int ReportError( 
   UINT nType = MB_OK, 
   UINT nMessageID = 0  
);

Parametry

  • nType
    Określa styl okna komunikatu.Zastosuj dowolną kombinację Style okno komunikatu do pola.Jeśli ten parametr nie jest określony, domyślnie jest MB_OK.

  • nMessageID
    Określa identyfikator zasobów (ciąg spisu) wiadomości do wyświetlania, jeśli obiekt wyjątku nie jest komunikat o błędzie.Jeśli 0, wiadomość "komunikat o błędzie nie jest dostępny" jest wyświetlany.

Wartość zwracana

An AfxMessageBox value; inaczej 0, jeśli nie jest za mało pamięci, aby wyświetlić okno komunikatu.Zobacz AfxMessageBox możliwe wartości zwracanej.

Przykład

Poniżej przedstawiono przykład wykorzystania CException::ReportError.Innym przykładem, zobacz przykład dla połowu.

CFile fileInput;
CFileException ex;

// try to open a file for reading.   
// The file will certainly not 
// exist because there are too many explicit 
// directories in the name. 

// if the call to Open() fails, ex will be 
// initialized with exception 
// information.  the call to ex.ReportError() will 
// display an appropriate 
// error message to the user, such as 
// "\Too\Many\Bad\Dirs.DAT contains an 
// invalid path."  The error message text will be 
// appropriate for the 
// file name and error condition. 

if (!fileInput.Open(_T("\\Too\\Many\\Bad\\Dirs.DAT"), CFile::modeRead, &ex))
{
   ex.ReportError();
}
else
{
   // the file was opened, so do whatever work 
   // with fileInput we were planning...

   fileInput.Close();
}

Wymagania

Nagłówek: afx.h

Zobacz też

Informacje

Klasa CException

Diagram hierarchii

AfxMessageBox

CFileException::GetErrorMessage