Hello,
for debugging purposes, I am using next base class for my exception
classes:
class ErrorBase
{
/*- Class invariants : What must be true after each call to a public
* interface
*/
public:
explicit ErrorBase( const std::string &txt );
ErrorBase( const ErrorBase &rhs );
virtual ~ErrorBase();
ErrorBase& operator=( const ErrorBase &rhs );
virtual std::ostream& Print( std::ostream &stream ) const;
private:
void CreateMessage( std::ostream &stream ) const;
virtual void PrintDetails( std::ostream & ) const;
std::string txt;
};
then I use something like this:
class RandomError : public ErrorBase
{
//implementation
}
const std::string errorMsg( __FILE__ + __LINE__ + "error message" );
throw RandomError( errorMsg );
I read on lots of places that the exception class should inherit from
the std::exception class and should not use std::string, because it can
throw. This article explains the problem:
http://www.boost.org/community/error_handling.html
Can anyone recommend me a better way to implement the exception
handling, which is going to give the runtime message when the error
class is thrown?
Thanks in advance.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]