Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use BOOST_THROW_EXCEPTION?

How do I use the BOOST_THROW_EXCEPTION macro? What goes in as parameters? I have no clue and I cannot seem to find any readable examples.

like image 434
Jeroen Avatar asked Oct 21 '13 18:10

Jeroen


1 Answers

You just pass an exception object to it:

BOOST_THROW_EXCEPTION(std::range_error("Index out of range"));

It will wrap the exception to make it derive from class boost::exception (if it's not already a child of it), and add info like source file and line.

The Boost.Exception FAQ has good insights on advantages and use examples.

like image 171
CharlesB Avatar answered Oct 22 '22 05:10

CharlesB