CException::ReportError

调用该成员函数在消息框中显示错误文本用户报告。

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

参数

  • nType
    指定消息框的样式。 适用于 消息框样式 的任意组合框。 如果未指定此参数,则默认值为 MB_OK

  • nMessageID
    指定资源ID (字符串表项)消息显示,如果异常对象没有一条错误消息。 如果为 0,消息“错误消息不可用”显示。

返回值

AfxMessageBox 值;否则0,如果未显示消息框足够的内存。 对于可返回值 AfxMessageBox 参见。

示例

这是使用的示例 CException::ReportError。 有关其他示例,请 "CATCH"请参见示例。

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();
}

要求

Header: afx.h

请参见

参考

CException Class

层次结构图

AfxMessageBox

CFileException::GetErrorMessage