Use BOOST_THROW_EXCEPTION macro to throw

This is necessary if boost is compiled without support for exceptions.