Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost exceptions

Do all boost exceptions derive from std::exception? If not do they all derive from some base exception class?

like image 875
Net Citizen Avatar asked Jun 28 '09 17:06

Net Citizen


3 Answers

According to the documentation boost::exception doesn't inherit std::exception.

The FAQ explains why.

However this page explains how to correctly use Boost exceptions.

like image 178
Ahmad Mushtaq Avatar answered Nov 12 '22 05:11

Ahmad Mushtaq


A "good Boost citizen" library should throw using boost::throw_exception, in order to support configurations where exception handling is disabled.

The boost::throw_exception function requires that the type of the passed exception derives publicly from std::exception (as of version 1.37.0 or thereabouts boost::throw_exception will issue a compile error if that requirement is not met.) In addition and by default, exceptions emitted using boost::throw_exception derive from boost::exception.

However, there is no requirement for Boost libraries to throw exceptions through boost:throw_exception or to derive from std::exception.

like image 24
Emil Avatar answered Nov 12 '22 04:11

Emil


I believe so. Can't think of a boost library throwing something non-std::exception based.

like image 1
Assaf Lavie Avatar answered Nov 12 '22 05:11

Assaf Lavie