Opened 9 years ago

Closed 9 years ago

#2821 closed Patches (wontfix)

Can not define custom description for boost::error_info

Reported by: paul.kolomiets@… Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:


There is no way to make use of the error_info::value_as_string method override. I can create error_info descendants, but only base class copy will be committed in the exception storage by the << operator:

template <class E,class Tag,class T,class Base>
E const &
operator<<( E const & x, error_info<Tag,T> const & v )
   typedef error_info<Tag,T> error_info_tag_t;
   shared_ptr<error_info_tag_t> p( new error_info_tag_t(v) );

   // Why new error_info_tag_t?
   // v can be another of another type.

See attached sample. It will describe os_error_info_tag as "10" instead of "Error code: 10".

I've make a patch to solve this issue. It is rather ugly, but it works. Please review my changes. And can you let me know if you find better way to fix this issue? Thanks.

Attachments (2)

test.cpp (752 bytes) - added by paul.kolomiets@… 9 years ago.
issue reproduce test
boost_exception.patch (8.5 KB) - added by paul.kolomiets@… 9 years ago.
proposed fix

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by paul.kolomiets@…

Attachment: test.cpp added

issue reproduce test

Changed 9 years ago by paul.kolomiets@…

Attachment: boost_exception.patch added

proposed fix

comment:1 Changed 9 years ago by Emil Dotchevski

Resolution: wontfix
Status: newclosed

This is by design: error_as_string is an implementation detail. The formal documentation for error_info is here:

The latest version supports what you want in a different way; for example error_info<tag_foo_error,int> can be printed differently from error_info<tag_bar_error,int> by diagnostic_information. See for details.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Emil Dotchevski.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.