Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

CError.cpp

Go to the documentation of this file.
00001 
00034 #include "stdafx.h"
00035 #include "CError.h"
00036 
00037 namespace AxPipe {
00039     void
00040     CError::InError(int iError, _TCHAR *szError) {
00041         if (m_pPrev) {
00042             m_pPrev->InError(iError, szError);
00043         } else {
00044             if (m_iError != ERROR_CODE_SUCCESS) {
00045                 delete[] szError;           // Free the message, won't happen otherwise
00046                 return;                     // Always keep the first error reported, assume it's the 'root' cause
00047             }
00048             delete[] m_szError;             // If there happens to be something before...
00049             m_szError = szError;
00050             m_iError = iError;
00051         }
00052     }
00054     void
00055     CError::Init(CError *pPrev) {
00056         m_pPrev = pPrev;
00057     }
00059     CError::CError() {
00060         m_szError = NULL;
00061         m_pPrev = NULL;
00062         m_iError = ERROR_CODE_SUCCESS;
00063     }
00065     CError::~CError() {
00066         delete[] m_szError;
00067     }
00071     void
00072     CError::SetError(int iError, const _TCHAR *szError, const _TCHAR *szParam) {
00073         // wsprintf has a hard-coded limit of 1024.
00074         _TCHAR *szFmtError = new _TCHAR[1024];
00075         if (szFmtError) {
00076             // Use wprintf so as not to include the c-run time library version, for size.
00077             wsprintf(szFmtError, szError, szParam);
00078             InError(iError, szFmtError);
00079         }
00080     }
00084     _TCHAR *
00085     CError::GetErrorMsg() {
00086         if (m_pPrev) {
00087             return m_pPrev->GetErrorMsg();
00088         } else {
00089             return m_szError;
00090         }
00091     }
00095     int
00096     CError::GetErrorCode() {
00097         if (m_pPrev) {
00098             return m_pPrev->GetErrorCode();
00099         } else {
00100             return m_iError;
00101         }
00102     }
00103 };

Generated on Mon Feb 2 13:19:18 2004 for AxPipe by doxygen 1.3.5