
AMDG On 06/23/2012 04:19 PM, Robert Ramey wrote:
or if you want to add your own sauce
catch(std::exception &e){ std::exception_ptr e = std::current_exception(); someclass se(e, extra stuff); // home brew or from some library std::throw(se); }
or if you want to catch anyone's stuff
catch(...){ std::exception_ptr e = std::current_exception(); my_unknown_exception me(e); // though its not clear what the upper level could do with this }
this would confine the usage of boost exception to areas where the user can decide whether or not he want's to use it. It looks to me that the standard was conceived to support just this usage.
I disagree. std::exception_ptr was primarily designed to allow exceptions to be passed between threads. The interface doesn't allow you to do much besides rethrowing it unchanged.
It doesn't require anything special at the throw point. The standard facility of using one's own exception class is sufficient.
Doing this means that the caller has to catch someclass or my_unknown_exception instead of boost::archive_exception. It's true that using exception_ptr preserves all the information from the original exception, but it doesn't do it in a very convenient or accessible way. Even worse, if you use this in pre-existing code, you've just introduced a breaking change, because the type of the exception that comes out is different.
If the point of this catch is to translate the type of the exception object, it has to look like:
<snip>
And of course this nonsense has to go around every call to Boost Serialization.
WHY?
lol - well you've got a point here. But I not convinced a huge problem in practice. I would expect most of these would be placed at the much higer levels.
I don't see why that would be the case. The point of using Boost.Exception is to be able to add context information to any exception as it goes by, not to do any real error handling.
How is this different from using std::exception ?
You can't add your own stuff to a live std::exception.
I believe equivalent functionality is available. I believe that boost exception is more intrusive that it has to be.
Boost.Exception helps keep the exception hierarchy clean. a) The type of the exception indicates the actual error that occurred and contains any information specific to the error. b) boost::exception contains various information about the context of the exception. Your latest solution mixes (a) and (b) in a way that makes (a) difficult to get at. In Christ, Steven Watanabe