本文整理汇总了C++中CError::SetSeverity方法的典型用法代码示例。如果您正苦于以下问题:C++ CError::SetSeverity方法的具体用法?C++ CError::SetSeverity怎么用?C++ CError::SetSeverity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CError
的用法示例。
在下文中一共展示了CError::SetSeverity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThrowAssertion
// ** When an exception is thrown, execution of the current function is stopped and
// jumps directly to the catch block of the innermost exception frame. The
// exception mechanism bypasses the normal exit path from a function. Therefore,
// you must be sure to delete those memory blocks that would be deleted in a
// normal exit.
// static
void Library::ThrowAssertion(LPCSTR lpszFilename, int nLine,
LPCSTR lpszExpression, LPCSTR lpszError/*=NULL*/)
{
// CAppException* pe = new CAppException(TRUE); // pass true if creating on the heap
// Bug: can't just copy LPCTSTR pointer to string, because it might be a temporary object.
// The error message was getting overwritten with FE EE's and didn't know what was going on -
// a CString was being passed here and then going out of scope because of the throw -
// so use strcpy or CStrings
// pe->m_pszError = pszError; // store error message
// pe->m_strError = "Assertion Failed";
// throw pe;
// CError e(_T("Assertion Failed"), TRUE);
// e.SetFileLocation(lpszFilename, nLine, lpszExpression);
// HandleError(e);
// CError e(FALSE); // false because created on the stack
// e.SetName(_T("Assertion Failed"));
// e.SetSeverity(TRUE);
// e.SetFileLocation(lpszFilename, nLine, lpszExpression);
// throw &e;
CError* pe = new CError(TRUE);
if (lpszError==NULL)
pe->SetName(_T("Assertion Failed"));
else
pe->SetName(lpszError);
pe->SetSeverity(TRUE);
pe->SetFileLocation(lpszFilename, nLine, lpszExpression);
throw pe;
}