On Nov 27, 2013 9:52 PM, "Emil Dotchevski"
On Wed, Nov 27, 2013 at 8:19 AM, Egor Tensin
wrote:
The issue that's confusing me arose from my intention of inheriting my exception classes from std::runtime_error rather than from std::exception. It seemed logical to me, as my exceptions are really runtime errors; getting something meaningful via what() also seemed like a good idea. However, this doesn't compile:
<cut>
struct foo_error : virtual boost::exception, virtual std::runtime_error { explicit foo_error(const char *const what) : std::runtime_error(what) { }
Yes, you'd have to use non-virtual inheritance if you want to be able to pass the what parameter like this. However, I would recommend deriving virtually from std::exception and using different exception types rather than different what strings for different failures. It is usually appropriate to override what() and implement it in terms of diagnostic_information_what (see
www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information_what.html .) Your advice makes sense to me but I'm curious what semantics you write off, either explicit in the runtime_error definition or implied by library or development tool interpretation of runtime_error.
-- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users