Closed sdebionne closed 4 years ago
I don't see why you think that would be possible. If you substitute the definition of BOOST_THROW_EXCEPTION you quote into the expression, the result is the exact same error.
My bad, I screw up with the parenthesis when reading the documentation, sorry. It would be nice to have though. Maybe something like this could be helpful
BOOST_THROW_EXCEPTION2(
std::runtime_error("oupsy"),
(boost::errinfo_errno(res))(boost::errinfo_file_name(filename))
)
or
boost::throw_exception(BOOST_EXCEPTION(std::runtime_error("oupsy")) << boost::errinfo_errno(res)) << boost::errinfo_file_name(filename));
or is there any other recommended way to achieve the same goal, that is, throw a boost exception with the function, file and line infos plus additional errinfos?
The current way is
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("oops")) << boost::errinfo_errno(res));
but this rarely occurs in practice because you typically throw your own exception type which already derives from boost::exception
so the call to boost::enable_error_info
is not necessary.
(In 1.73, there will be changes to throw_exception
, but they don't affect this issue. See https://www.boost.org/doc/libs/develop/libs/throw_exception/doc/html/throw_exception.html.)
Thanks, Boost.ThrowException has everything I need in the end!
AFAIU from the documentation that defines BOOST_THROW_EXCEPTION as
it should be possible to write
But looking at the current implementation of
BOOST_THROW_EXCEPTION
it looks like it's not possible anymore.
Is this an oversight?