| |
15 |
15 |
|
| |
16 |
16 |
|
| |
17 |
17 |
|
| |
18 |
18 |
|
| |
19 |
19 |
#include "stdafx.h" |
| |
20 |
20 |
#include "TBaseException.h" |
| |
21 |
21 |
#include <atltrace.h> |
| |
22 |
22 |
|
| |
23 |
23 |
namespace chcore |
| |
24 |
24 |
{ |
| |
25 |
25 |
TBaseException::TBaseException(EGeneralErrors eErrorCode, const wchar_t* pszMsg, const wchar_t* pszFile, size_t stLineNumber, const wchar_t* pszFunction) : |
| |
26 |
26 |
m_eErrorCode(eErrorCode), |
| |
27 |
27 |
m_pszMsg(pszMsg), |
| |
28 |
28 |
m_pszFile(pszFile), |
| |
29 |
29 |
m_pszFunction(pszFunction), |
| |
30 |
30 |
m_stLineNumber(stLineNumber) |
| |
31 |
31 |
{ |
| |
32 |
32 |
ATLTRACE(_T("*** Base Exception is being thrown:\n\tMsg: %s\n\tError code: %d\n\tFile: %s\n\tLine number: %ld\n\tFunction: %s\n"), pszMsg, eErrorCode, pszFile, stLineNumber, pszFunction); |
| |
33 |
33 |
} |
| |
34 |
34 |
|
| |
35 |
|
TBaseException::TBaseException(const TBaseException& rSrc) : |
| |
36 |
|
m_eErrorCode(rSrc.m_eErrorCode), |
| |
37 |
|
m_pszMsg(rSrc.m_pszMsg), |
| |
38 |
|
m_pszFile(rSrc.m_pszFile), |
| |
39 |
|
m_pszFunction(rSrc.m_pszFunction), |
| |
40 |
|
m_stLineNumber(rSrc.m_stLineNumber) |
| |
41 |
|
{ |
| |
42 |
|
} |
| |
43 |
|
|
| |
44 |
|
TBaseException& TBaseException::operator=(const TBaseException& rSrc) |
| |
45 |
|
{ |
| |
46 |
|
if(this != &rSrc) |
| |
47 |
|
{ |
| |
48 |
|
m_eErrorCode = rSrc.m_eErrorCode; |
| |
49 |
|
m_pszMsg = rSrc.m_pszMsg; |
| |
50 |
|
m_pszFile = rSrc.m_pszFile; |
| |
51 |
|
m_pszFunction = rSrc.m_pszFunction; |
| |
52 |
|
m_stLineNumber = rSrc.m_stLineNumber; |
| |
53 |
|
} |
| |
54 |
|
|
| |
55 |
|
return *this; |
| |
56 |
|
} |
| |
57 |
|
|
| |
58 |
35 |
TBaseException::~TBaseException() |
| |
59 |
36 |
{ |
| |
60 |
37 |
} |
| |
61 |
38 |
|
| |
62 |
39 |
void TBaseException::GetErrorInfo(wchar_t* pszBuffer, size_t stMaxBuffer) const |
| |
63 |
40 |
{ |
| |
64 |
41 |
_snwprintf_s(pszBuffer, stMaxBuffer, _TRUNCATE, _T("%s (error code: %d)"), |
| |
65 |
42 |
m_pszMsg, m_eErrorCode); |
| |
66 |
43 |
pszBuffer[stMaxBuffer - 1] = _T('\0'); |
| |
67 |
44 |
} |
| |
68 |
45 |
|
| |
69 |
46 |
void TBaseException::GetDetailedErrorInfo(wchar_t* pszBuffer, size_t stMaxBuffer) const |
| |
70 |
47 |
{ |
| |
71 |
48 |
_snwprintf_s(pszBuffer, stMaxBuffer, _TRUNCATE, _T("%s\r\nError code: %d\r\nFile: %s\r\nFunction: %s\r\nLine no: %lu"), |
| |
72 |
49 |
m_pszMsg, m_eErrorCode, m_pszFile, m_pszFunction, (unsigned long)m_stLineNumber); |
| |
73 |
50 |
pszBuffer[stMaxBuffer - 1] = _T('\0'); |
| |
74 |
51 |
} |
| |
75 |
52 |
} |