Re:Does ROOT handles C++ exceptions

Masaharu Goto (MXJ02154@nifty.ne.jp)
Mon, 20 Jul 1998 15:35:00 +0900


Konstantin,

>Folks, how does ROOT handle C++ exceptions? Does it?
>
>This is what I do: I have a class that has a method that throws a C++
>exception. When I call this method interactively from the ROOT
>command line, ROOT bombs out (on WinNT the ROOT process just exits with
>the "abnormal program termination" message). It looks as if my
>exception is not caught by ROOT, but is passed to the system default
>exception catcher. I did not try this on any UNIX system, should I?
>I am using the ROOT 2.00/09 on WinNT4.0sp3.
>
>So my question is: how do I prevent ROOT from bombing out?

ROOT/CINT does not hanbdle C++ exception.

>I did try to type in the command enclosed into a try/catch block
>(root% try { myObject.myMethod() } catch (...) {}). ROOT did not complain,
>called myMethod (which throes the exception) and bombed out, as if
>try/catch were not there.

To be precise, CINT parses and handles exception only within interpreted
code to some extent. But CINT can not catch exception from precompiled code.
Also, CINT's exception handing is very premature even in purely interpreted
code. Please do not rely on it.

>Should I give up on trying to use C++ exceptions with ROOT?

Right now, you need to give up using C++ exceptions.

Masaharu Goto