AnimatLab  2
Test
StdErrorInfo.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 
9 namespace StdUtils
10 {
11 
19 {
20  m_lError = 0;
21  m_lSourceLine = 0;
22 }
23 
35 CStdErrorInfo::CStdErrorInfo(long lError, std::string strError, std::string strSourceFile, long lSourceLine)
36 {
37  m_lError = lError;
38  m_strError = strError;
39  m_strSourceFile = strSourceFile;
40  m_lSourceLine = lSourceLine;
41 }
42 
50 {
51 
52 try
53 {
54  m_aryCallChain.RemoveAll();
55 }
56 catch(...)
57 {Std_TraceMsg(0, "Caught Error in desctructor of CStdErrorInfo\n", "", -1, false, true);}
58 }
59 
68 std::string CStdErrorInfo::Log()
69 {
70  std::string strText;
71 
72  strText = "\r\nErrorNum: " + STR(m_lError) + "\r\n" +
73  "ErrorMsg: " + STR(m_strError) + "\r\n" +
74  "Source: " + m_strSourceFile + "(" + STR(m_lSourceLine) + ")\r\n\r\n";
75 
76  int iCount = m_aryCallChain.GetSize();
77  if(iCount) strText += "RelayPath\r\n";
78  for(int iIndex=0; iIndex<iCount; iIndex++)
79  strText += m_aryCallChain[iIndex] + "\r\n";
80 
81  strText += "\r\n\r\n";
82  LOG_ERROR(strText);
83 
84  return strText;
85 }
86 
88 {
89  std::string strOut = "Source file: " + m_strSourceFile + "\r\nSource Line: " + STR(m_lSourceLine) + "\r\nStack Trace: \r\n";
90  int iCount = m_aryCallChain.GetSize();
91  for(int iIdx=0; iIdx<iCount; iIdx++)
92  strOut += m_aryCallChain[iIdx];
93 
94  return strOut;
95 }
96 
97 } //StdUtils
std::string m_strSourceFile
The source file name where the error occurred.
Definition: StdErrorInfo.h:32
std::string m_strError
The error message.
Definition: StdErrorInfo.h:26
virtual std::string StackTrace()
Gets the stack trace.
long m_lError
The error number.
Definition: StdErrorInfo.h:23
CStdArray< std::string > m_aryCallChain
The call chain of the errorr.
Definition: StdErrorInfo.h:35
long m_lSourceLine
The source line code line where the error occurred.
Definition: StdErrorInfo.h:29
Namespace for the standard utility objects.
Definition: MarkupSTL.cpp:19
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
virtual std::string Log()
Logs the error to the loggin mechanism.
CStdErrorInfo()
Default constructor.
~CStdErrorInfo()
Destructor.