Re: [ROOT] Does root support exception mechanism?

From: George Heintzelman (gah@bnl.gov)
Date: Wed May 31 2000 - 18:56:51 MEST


> Hi Zhou,
> 
>    ROOT does not yet use exceptions since it is not yet available
> on all platforms supported by ROOT. However, you should be able to use
> exceptions in your own code.

It's actually a little worse than this. There are two additional 
problems:

1) Many ROOT routines are not 'exception-safe', ie, they cannot stand 
having an exception propagated up through them without memory leaks or 
worse (odd program states, for example). Fixing this would be a lot of 
work (and a lot of combing through code) for the developers but really 
ought to be done at some point, if exceptions are ever going to really 
be supported. So calling an exception from a routine intended to be 
called (via virtual functions) from a ROOT object is probably not the 
wisest thing to do, unless you know you will catch the exception before 
it goes through ROOT code.

Of course, many standard library routines throw exceptions 

2) CINT does not allow you to catch exceptions thrown in compiled code 
in interpreted code. The best you can do is catch it in the interpreter 
and have it dump you to the command line, by compiling with 
G__EXCEPTIONWRAPPER defined. There has been discussion of how to make 
this a little less restrictive but as far as I know nothing has 
actually been implemented in this regard.

So exceptions are really not too useful except for error handling 
within code that doesn't go through ROOT.

George Heintzelman
gah@bnl.gov



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:27 MET