boostorg / exception

Boost.org exception module
http://boost.org/libs/exception
Boost Software License 1.0
15 stars 46 forks source link

feature request: throw_exception customization point #25

Closed zlojvavan closed 4 years ago

zlojvavan commented 5 years ago

what about introducing end user customization point facility? at the moment one can specialize throw_exception template using any specific type but providing specialization for the entire class hierarchy looks somewhat problematic

zajo commented 4 years ago

What customization do you need? The only reason you'd call throw_exception rather than just use throw is to support BOOST_NO_EXCEPTIONS configurations. It is always illegal to return from throw_exception.

zlojvavan commented 4 years ago

I'm not talking about returning from throw_exception for example one may want to replace exception instance with another class or just "enrich" it with say callstack info, etc.

zajo commented 4 years ago

Like I said, throw_exception is not a customization point. When a library author wants to throw an exception, it shouldn't be up to the user to change the exception type. It exists solely to allow Boost to be used under -fno-exceptions.

zlojvavan commented 4 years ago

it's not and that's why I filed request as it's better be that customization point. changing exception type is somewhat extreme example (though if the type is derived from the thrown type it won't really hurt) but enriching it by simple replacing text or adding extra info such as say call stack as demonstrated in BOOST_THROW_EXCEPTION macro and/or in https://www.boost.org/doc/libs/1_72_0/doc/html/stacktrace/getting_started.html#stacktrace.getting_started.exceptions_with_stacktrace is very useful feature