-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception.cpp
More file actions
45 lines (35 loc) · 960 Bytes
/
exception.cpp
File metadata and controls
45 lines (35 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "exception.h"
CException::CException(int nCode, const string& strMsg)
:m_nCode(nCode), m_strMsg(strMsg)
{
}
CException::CException(int nCode, const char* pszMsg)
:m_nCode(nCode), m_strMsg(pszMsg)
{
}
//CException::CException(int nCode, const char* pszMsg, ...)
// :m_nCode(nCode)
//{
// char szTmp[256];
// memset(szTmp, 0, sizeof(szTmp));
// va_list ap;
// va_start(ap, pszMsg);
// _vsnprintf(szTmp, sizeof(szTmp), pszMsg, ap);
// va_end(ap);
//
// m_strMsg.assign(szTmp);
//}
CException::~CException()
{
}
void ThrowException(int n, const char* pszMsg, ...)
{
char szTmp[512];
memset(szTmp, 0, sizeof(szTmp));
va_list ap;
va_start(ap, pszMsg);
vsnprintf(szTmp, sizeof(szTmp)-1, pszMsg, ap);
va_end(ap);
cout<<szTmp<<n<<endl;
throw CException(n, szTmp);
}