📄 abexception.cpp
字号:
#include "stdafx.h"
#include <sstream>
#include "AbException.h"
CAbException::CAbException() throw()
: exception(),m_uError(0),m_strFile(""),m_uLine(0l),m_bSystem(true)
{
#ifdef _DEBUG
m_uError=::GetLastError();
m_bSystem=true;
DebugOutput();
#endif
}
CAbException::CAbException(unsigned u) throw()
: exception(),m_uError(u),m_strFile(""),m_uLine(0l),m_bSystem(true)
{
#ifdef _DEBUG
DebugOutput();
#endif
}
CAbException::CAbException(unsigned u,const char *f,unsigned l,bool bSystem) throw()
: exception(),m_uError(u),m_strFile(f),m_uLine(l),m_bSystem(bSystem)
{
#ifdef _DEBUG
DebugOutput();
#endif
}
void CAbException::DebugOutput()
{
#ifdef _DEBUG
string str=GetMessage();
::OutputDebugString(str.c_str());
#endif
}
string CAbException::GetMessage() const
{
string strTheMsg;
if(m_bSystem) {
void far *lpMsgBuf;
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,m_uError,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
(LPSTR)&lpMsgBuf,0,NULL);
strTheMsg=reinterpret_cast<char far*>(lpMsgBuf);
LocalFree( lpMsgBuf );
}else{
switch(m_uError) {
case err_ResourceLeak:
strTheMsg="Resource Leak";
break;
}
}
stringstream stmTemp;
stmTemp << strTheMsg << " in File:" << m_strFile << ", Line:" << m_uLine << ends;
strTheMsg=stmTemp.str();
return strTheMsg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -