c++: Test if code is in a catch block
===

I am trying to make a generic exception framework based on boost::exception.
For that, I use macro like this one:

    #define AR_THROW_EXCEPTION(internalMessage)\
    BOOST_THROW_EXCEPTION(boost::enable_current_exception(ArException())\
    << internal_message(internalMessage)\
    << inner_exception(boost::current_exception()))

My problem is that "boost::current_exception()" will terminate my program if it is not called from a catch block.
To avoid to define a second macro "AR_RETHROW_EXCEPTION", I would like to be able to do

    #define AR_THROW_EXCEPTION(internalMessage)\
    BOOST_THROW_EXCEPTION(boost::enable_current_exception(ArException())\
    << internal_message(internalMessage)\
    if (IS_IN_CATCH_BLOCK)\
    << inner_exception(boost::current_exception()))

Do anybody know a way ?


