Ticket #2821 (closed Patches: wontfix)

Opened 8 years ago

Last modified 8 years ago

Can not define custom description for boost::error_info

Reported by: paul.kolomiets@… Owned by: emildotchevski
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.


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

Change History

Changed 8 years ago by paul.kolomiets@…

issue reproduce test

Changed 8 years ago by paul.kolomiets@…

proposed fix

comment:1 Changed 8 years ago by emildotchevski

  • Status changed from new to closed
  • Resolution set to wontfix

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.


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

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

Note: See TracTickets for help on using tickets.