On Mon, Dec 10, 2012 at 3:37 AM, Marco Craveiro
wrote:
Hi boost users,
I'm a very happy user of both error_code and exception, but now I
found a new use case which is to combine them. So I'm looking for an
example of how to add an error_code into an exception and get it all
nicely formatted with diagnostic_information. I can see how to use
error_info [1] but not error_code. Any pointers would be appreciated.
#include
typedef boost::error_info error_code_;
With this, you can store error_code_ into any exceptions deriving from
boost::exception. You can then overload to_string() and use the
observers of boost::error_code to define how it appears in the string
returned by boost::diagnostic_information:
namespace boost { namespace system {
std::string to_string( error_code const & ec )
{
return .....;
}
} }
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode