Opened 14 years ago
Closed 14 years ago
#2821 closed Patches (wontfix)
Can not define custom description for boost::error_info
Reported by: | Owned by: | Emil Dotchevski | |
---|---|---|---|
Milestone: | To Be Determined | Component: | exception |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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> inline 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)
Change History (3)
by , 14 years ago
comment:1 by , 14 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is by design: error_as_string is an implementation detail. The formal documentation for error_info is here: http://www.boost.org/doc/libs/release/libs/exception/doc/error_info.html.
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 http://www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information.html for details.
issue reproduce test