exception.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2013.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file support/exception.hpp
  9. * \author Andrey Semashev
  10. * \date 18.07.2009
  11. *
  12. * This header enables Boost.Exception support for Boost.Log.
  13. */
  14. #ifndef BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
  15. #define BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
  16. #include <boost/exception/info.hpp>
  17. #include <boost/log/detail/config.hpp>
  18. #include <boost/log/attributes/attribute_name.hpp>
  19. #include <boost/log/attributes/named_scope.hpp>
  20. #include <boost/log/utility/type_info_wrapper.hpp>
  21. #include <boost/log/detail/header.hpp>
  22. #ifdef BOOST_HAS_PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. namespace boost {
  26. BOOST_LOG_OPEN_NAMESPACE
  27. /*!
  28. * Attribute name exception information
  29. */
  30. typedef error_info< struct attribute_name_info_tag, attribute_name > attribute_name_info;
  31. /*!
  32. * Type info exception information
  33. */
  34. typedef error_info< struct type_info_info_tag, type_info_wrapper > type_info_info;
  35. /*!
  36. * Parse position exception information
  37. */
  38. typedef error_info< struct position_info_tag, unsigned int > position_info;
  39. /*!
  40. * Current scope exception information
  41. */
  42. typedef error_info< struct current_scope_info_tag, attributes::named_scope_list > current_scope_info;
  43. /*!
  44. * The function returns an error information object that contains current stack of scopes.
  45. * This information can then be attached to an exception and extracted at the catch site.
  46. * The extracted scope list won't be affected by any scope changes that may happen during
  47. * the exception propagation.
  48. *
  49. * \note See the \c named_scope attribute documentation on how to maintain scope list.
  50. */
  51. inline current_scope_info current_scope()
  52. {
  53. return current_scope_info(attributes::named_scope::get_scopes());
  54. }
  55. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  56. } // namespace boost
  57. #include <boost/log/detail/footer.hpp>
  58. #endif // BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_