|
From: stephan b. <sg...@us...> - 2004-12-24 16:48:44
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2556/src Modified Files: Exception.cpp Log Message: added where() method. Had to do a small amount of refactoring. Index: Exception.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Exception.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Exception.cpp 23 Dec 2004 02:25:32 -0000 1.2 +++ Exception.cpp 24 Dec 2004 16:48:04 -0000 1.3 @@ -23,12 +23,17 @@ namespace P { Exception::Exception(const char* what, const SourceInfo& si) throw() -: _what(what), _source(&si) + : _what(what), _source(&si), _where() +{ +} + +Exception::Exception(const std::string & what, const SourceInfo& si) throw() + : _what(what), _source(&si), _where() { } Exception::Exception(const Exception& err) throw() -: _what(err._what), _source(err._source) + : _what(err._what), _source(err._source), _where(err._where) { } @@ -36,9 +41,24 @@ { } +const char * Exception::where() const throw() +{ + if( _where.empty() && _source ) + { + _where = "[file = "; + _where += _source->file(); + _where += " : line = "; + _where += _source->line(); + _where += " : function = "; + _where += _source->func(); + _where += "]"; + } + return _where.c_str(); +} + const char* Exception::what() const throw() { - return _what; + return _what.c_str(); } Exception& Exception::operator=(const Exception& err) throw() |