00001 #include "gn/gnException.h"
00002
00003 void gnException::AddCaller(const char* const function)
00004 {
00005 string func(function);
00006 string pretty_func = func.substr(0, func.find('(')+1);
00007 pretty_func += func.substr(func.rfind(')'), func.length());
00008 function_trace.push_back(pretty_func);
00009 }
00010
00011 ostream& operator<<(ostream& os, const gnException& gne){
00012
00013 os << "Exception " << gne.m_code.GetName() << " thrown ";
00014 list<string>::const_iterator func_iter = gne.function_trace.begin();
00015
00016
00017 if(func_iter != gne.function_trace.end()){
00018 os << "from\n" << *func_iter << " in " << gne.m_file << " " << gne.m_line;
00019 func_iter++;
00020 }
00021
00022
00023 while(func_iter != gne.function_trace.end()){
00024 os << "\nCalled by " << *func_iter;
00025 func_iter++;
00026 }
00027 if(gne.m_message.length() > 0)
00028 os <<"\n" << gne.m_message;
00029 os << "\n";
00030 return os;
00031 }