Hi,
I belive it will be good for class TException to have constructor that
accepted arguments as function printf (or iostream::form()):
Something like this:
#include <cstdarg>
#include <exception>
#include "TNamed.h"
class TException : public std::exception, public TNamed
{
public:
virtual ~TException (void) {}
TException (const TException &e) {*this=e;}
TException (const char *format,...);
TException &operator = (const TException &e);
const char *what (void) const {return GetTitle();}
};
inline
TException::TException(const char *format,...)
{
char *the_name = new char [10000];
va_list ap;
va_start(ap,format);
vsprintf(the_name,format,ap); // There is no boundary check here. (bug)
va_end(ap);
SetName("ROOT exception");
SetTitle(the_name);
delete [] the_name;
}
inline
TException &operator = {const TException &e)
{
if( this!=&e)
TNamed::operator = (e);
return *this;
}
-----------------------
Example of code:
void f(void)
{
throw TException("Hello%c",'!');
}
int main()
{
try
{
f();
}
catch(std::exception &e)
{
cerr << e.what() << endl;
}
}
With best wishes,
Alexander Zvyagin.
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET