22 #ifndef NDN_CXX_UTIL_EXCEPTION_HPP
23 #define NDN_CXX_UTIL_EXCEPTION_HPP
29 #include <boost/exception_ptr.hpp>
30 #include <boost/exception/enable_current_exception.hpp>
31 #include <boost/exception/enable_error_info.hpp>
32 #include <boost/exception/errinfo_errno.hpp>
33 #include <boost/exception/errinfo_nested_exception.hpp>
35 #ifdef NDN_CXX_HAVE_STACKTRACE
36 #include <boost/stacktrace/stacktrace.hpp>
42 #ifdef NDN_CXX_HAVE_STACKTRACE
53 #ifdef NDN_CXX_HAVE_STACKTRACE
54 #define NDN_DETAIL_THROW_STACKTRACE \
55 << ndn::exception::errinfo_stacktrace(boost::stacktrace::stacktrace())
57 #define NDN_DETAIL_THROW_STACKTRACE
61 #define NDN_THROW(e) \
62 throw boost::enable_current_exception(boost::enable_error_info(e)) \
63 << boost::throw_file(__FILE__) \
64 << boost::throw_line(__LINE__) \
65 << boost::throw_function(__func__) \
66 NDN_DETAIL_THROW_STACKTRACE
68 #define NDN_THROW_ERRNO(e) \
69 NDN_THROW(e) << boost::errinfo_errno(errno)
71 #define NDN_THROW_NESTED(e) \
72 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