Boost C++ Libraries: Ticket #2821: Can not define custom description for boost::error_info https://svn.boost.org/trac10/ticket/2821 <p> 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 &lt;&lt; operator: </p> <pre class="wiki">template &lt;class E,class Tag,class T,class Base&gt; inline E const &amp; operator&lt;&lt;( E const &amp; x, error_info&lt;Tag,T&gt; const &amp; v ) { typedef error_info&lt;Tag,T&gt; error_info_tag_t; shared_ptr&lt;error_info_tag_t&gt; p( new error_info_tag_t(v) ); // Why new error_info_tag_t? // v can be another of another type. //... </pre><p> See attached sample. It will describe os_error_info_tag as "10" instead of "Error code: 10". </p> <p> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2821 Trac 1.4.3 paul.kolomiets@… Tue, 03 Mar 2009 07:28:49 GMT attachment set https://svn.boost.org/trac10/ticket/2821 https://svn.boost.org/trac10/ticket/2821 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> issue reproduce test </p> Ticket paul.kolomiets@… Tue, 03 Mar 2009 07:29:22 GMT attachment set https://svn.boost.org/trac10/ticket/2821 https://svn.boost.org/trac10/ticket/2821 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_exception.patch</span> </li> </ul> <p> proposed fix </p> Ticket Emil Dotchevski Thu, 26 Mar 2009 01:40:52 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2821#comment:1 https://svn.boost.org/trac10/ticket/2821#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> This is by design: error_as_string is an implementation detail. The formal documentation for error_info is here: <a href="http://www.boost.org/doc/libs/release/libs/exception/doc/error_info.html">http://www.boost.org/doc/libs/release/libs/exception/doc/error_info.html</a>. </p> <p> The latest version supports what you want in a different way; for example error_info&lt;tag_foo_error,int&gt; can be printed differently from error_info&lt;tag_bar_error,int&gt; by diagnostic_information. See <a href="http://www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information.html">http://www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information.html</a> for details. </p> Ticket