22 #ifndef NDN_CXX_UTIL_EXCEPTION_HPP
23 #define NDN_CXX_UTIL_EXCEPTION_HPP
29 #include <boost/exception_ptr.hpp>
30 #include <boost/exception/exception.hpp>
31 #include <boost/exception/errinfo_errno.hpp>
32 #include <boost/exception/errinfo_nested_exception.hpp>
34 #ifdef NDN_CXX_HAVE_STACKTRACE
35 #include <boost/stacktrace/stacktrace.hpp>
40 #ifdef NDN_CXX_HAVE_STACKTRACE
49 #define NDN_THROW_NO_STACK(e) \
50 throw ::boost::enable_current_exception(::boost::enable_error_info(e)) \
51 << ::boost::throw_file(__FILE__) \
52 << ::boost::throw_line(__LINE__) \
53 << ::boost::throw_function(__func__)
55 #ifdef NDN_CXX_HAVE_STACKTRACE
56 #define NDN_THROW(e) \
57 NDN_THROW_NO_STACK(e) << ::ndn::exception::errinfo_stacktrace(::boost::stacktrace::stacktrace())
59 #define NDN_THROW(e) NDN_THROW_NO_STACK(e)
62 #define NDN_THROW_ERRNO(e) \
63 NDN_THROW(e) << ::boost::errinfo_errno(errno)
65 #define NDN_THROW_NESTED(e) \
66 NDN_THROW(e) << ::boost::errinfo_nested_exception(::boost::current_exception())
Common includes and macros used throughout the library.
std::string to_string(const errinfo_stacktrace &x)
boost::error_info< struct stacktrace, boost::stacktrace::stacktrace > errinfo_stacktrace