Hi Alexander Zvyagin and ROOT'ers, On Fri, 28 Jan 2000 20:07:19 +0400 ZVYAGIN <ZVYAGIN@mx.ihep.su> wrote: > Hi, > > I belive it will be good for class TException to have constructor that > accepted arguments as function printf (or iostream::form()): I don't know if you actually looked at the sources I made avaliable (www.nbi.dk/~cholm/Downloads/). This is _exactly_ what I did. However, `TException' is an Abstract Base Class, and the children should define their constructor, to have variadic arguments! I've also provided examples (TWarning, TError, and TFatal) of this in the sources. However, the my simple suggestion of class TException : public std::excpetion, public TObject { ... } doesn't work. Rather the the class should be modifed to + class TException : public std::excpetion, public TObject - class TException { protected: Int_t fExitCode; // What to exit with Char_t* fLocation; // Where the exception was thrown Char_t* fErrorString; // What to write out public: TException(Int_t exit=kError, const Char_t* location=NULL); virtual void* Execute(void* arg=0)=0; + virtual const char* what(void) const { GetErrorString(); } virtual void SetErrorString(const Char_t* fmt, va_list ap); virtual Char_t* GetErrorString(void) const; virtual Int_t GetExitCode(void) const { return fExitCode; } ClassDef(TException,0) // ABC Exception class for ROOT } ; And it should be used as: try { ... throw new TWarning("Foo", "Something is wrong with Bar: %1", errno); } catch (exception* e) { cout << e->what() << endl; return errno; } That is it. Oh and to Rene Brun: > The MessageHandler is more general than an ExceptionHandler. > The ExceptionHandler can use the services of the Messagehandler. Yep. That's why I suggested the TException class! Cheers, Christian Holm Christensen ______________________________________________________________________ Address: Phone: (+45) 35 35 96 91 Sankt Hansgade 23, 1. th. Office: (+45) 353 25 307 DK-2200 Copenhagen N Web: www.nbi.dk/~cholm Denmark Email: cholm@nbi.dk
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET