On Wed, May 20, 2009 at 8:17 PM, Jon Kalb
Just wanted to ask if there were commonly accepted solutions to the following problem:
typedef boost::error_info
f1_descr; and then
throw f1exception() << f1_descr("blah blah blah").
and later
catch(f1exception & ex){...}
The constructor of std::string may throw an exception in which case f1exception will never be thrown. This is not necessarily the desired outcome as the intention was obviously to indicate f1exception error, not the string() error.
Jon Kalb raised this issue at BoostCon. My knee-jerk reaction was that it makes sense to alter the specification of operator<< so it never throws, but now my opinion is that it isn't a good idea. Consider this slightly modified example: std::string get_descr(); .... throw f1exception() << f1_descr(get_descr()); Even if operator<< and f1_descr's constructor never throw, in theory you could still get std::bad_alloc instead of f1exception. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode