Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

gnException.cpp

Go to the documentation of this file.
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         //write exception to stream.
00013         os << "Exception " << gne.m_code.GetName() << " thrown ";
00014         list<string>::const_iterator func_iter = gne.function_trace.begin();
00015 
00016         //print the original function
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         //print the call stack
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 }

Generated at Thu Apr 4 01:52:02 2002 for libGenome by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001