
Emil Dotchevski wrote:
On Fri, Oct 9, 2009 at 5:48 PM, denis
wrote: what do you think about exposing the error_info-map of boost::exception?
I would like to get all attached error infos from one exception.
I've never been able to do anything generic with the error_infos, other than dumping (user-unfriendly) diagnostic information, which is what boost::diagnostic_information is for.
I have an exception base-class which provides a virtual function user_message() where derived classes can generate a user-friendly message from their error_infos. See the example at the end.
Then, everyone could implement his own version of diagnostic_information() without relying on boost internals.
You do have some control over the output of diagnostic_information: [...]
Yes, but even if the output is not for end-users, I would like to keep the log-file as readable as possible for the support team. And not at least for me. For example I don't need the line "Throw in function (unknown)" (I rarely use BOOST_THROW_EXCEPTION) And I could use abi::__cxa_demangle to print a more readable name of an exception or error_info.
Beside that, I had another idea: When translating an exception it would be possible to copy all error_infos from the originating exception to the new one. How do you handle this loss of information at the time?
A copy of a boost::exception shares error_info ownership with the original. Does this work for your use case?
I don't think so. Where could I copy the exception in the
following example, so that my_error() would have the error_infos
from e?
struct my_error : public ex::exception {
virtual std::string
user_message () const {
// format() is just a little helper function in the base
// class using boost::get_error_info and boost::format
return format