At the catch site of a boost::exception (or std::exception), I want to iterate over all error_info elements of the exception, without knowing the types. I need to extract all the name-value pairs.
I guess it should possible since the boost::diagnostic_information function does that, but I'd like to avoid duplicating all that code.
Can this be done and how?
There's always the following information (iff you used
BOOST_THROW_EXCEPTION):Other than that you have use the
error_info_container, but thedata_member is private¹.If you are willing to "force" past that hurdle, the code to "duplicate" would not be so much:
Everything there is undocumented, not part of the public API though: it lives in namespace
boost::exception_detailand the classboost::exception_detail::exception_info_container_impl.In short, there be dragons (these interfaces are subject to change without notice and can depend on surprising assumptions).
¹ (except on some older compilers).