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