diff options
Diffstat (limited to 'boost/log/exceptions.hpp')
-rw-r--r-- | boost/log/exceptions.hpp | 102 |
1 files changed, 92 insertions, 10 deletions
diff --git a/boost/log/exceptions.hpp b/boost/log/exceptions.hpp index 8f305fabeb..32d55d40c5 100644 --- a/boost/log/exceptions.hpp +++ b/boost/log/exceptions.hpp @@ -20,6 +20,8 @@ #include <stdexcept> #include <boost/type_index.hpp> #include <boost/preprocessor/seq/enum.hpp> +#include <boost/system/error_code.hpp> +#include <boost/system/system_error.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/attributes/attribute_name.hpp> #include <boost/log/detail/header.hpp> @@ -59,6 +61,68 @@ BOOST_LOG_API void attach_attribute_name_info(exception& e, attribute_name const } // namespace aux /*! + * \brief Base class for memory allocation errors + * + * Exceptions derived from this class indicate problems with memory allocation. + */ +class BOOST_LOG_API bad_alloc : + public std::bad_alloc +{ +private: + std::string m_message; + +public: + /*! + * Initializing constructor. Creates an exception with the specified error message. + */ + explicit bad_alloc(const char* descr); + /*! + * Initializing constructor. Creates an exception with the specified error message. + */ + explicit bad_alloc(std::string const& descr); + /*! + * Destructor + */ + ~bad_alloc() throw(); + + /*! + * Error message accessor. + */ + const char* what() const throw(); + +#ifndef BOOST_LOG_DOXYGEN_PASS + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); +#endif +}; + +/*! + * \brief The exception is used to indicate reaching a storage capacity limit + */ +class BOOST_LOG_API capacity_limit_reached : + public bad_alloc +{ +public: + /*! + * Initializing constructor. Creates an exception with the specified error message. + */ + explicit capacity_limit_reached(const char* descr); + /*! + * Initializing constructor. Creates an exception with the specified error message. + */ + explicit capacity_limit_reached(std::string const& descr); + /*! + * Destructor + */ + ~capacity_limit_reached() throw(); + +#ifndef BOOST_LOG_DOXYGEN_PASS + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); +#endif +}; + +/*! * \brief Base class for runtime exceptions from the logging library * * Exceptions derived from this class indicate a problem that may not directly @@ -68,7 +132,7 @@ BOOST_LOG_API void attach_attribute_name_info(exception& e, attribute_name const class BOOST_LOG_API runtime_error : public std::runtime_error { -protected: +public: /*! * Initializing constructor. Creates an exception with the specified error message. */ @@ -101,7 +165,9 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name); #endif }; @@ -128,9 +194,13 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, typeindex::type_index const& type); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, typeindex::type_index const& type); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name, typeindex::type_index const& type); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name, typeindex::type_index const& type); #endif }; @@ -157,6 +227,7 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); #endif }; @@ -183,8 +254,11 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, std::size_t content_line); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, std::size_t content_line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name); #endif }; @@ -211,6 +285,7 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); #endif }; @@ -219,25 +294,23 @@ public: * \brief Exception class that is used to indicate underlying OS API errors */ class BOOST_LOG_API system_error : - public runtime_error + public boost::system::system_error { public: /*! - * Default constructor. Creates an exception with the default error message. - */ - system_error(); - /*! * Initializing constructor. Creates an exception with the specified error message. */ - explicit system_error(std::string const& descr); + system_error(boost::system::error_code code, std::string const& descr); /*! * Destructor */ ~system_error() throw(); #ifndef BOOST_LOG_DOXYGEN_PASS - static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); - static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, int system_error_code); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, int system_error_code); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, boost::system::error_code code); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, boost::system::error_code code); #endif }; @@ -250,7 +323,7 @@ public: class BOOST_LOG_API logic_error : public std::logic_error { -protected: +public: /*! * Initializing constructor. Creates an exception with the specified error message. */ @@ -259,6 +332,11 @@ protected: * Destructor */ ~logic_error() throw(); + +#ifndef BOOST_LOG_DOXYGEN_PASS + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); +#endif }; /*! @@ -283,6 +361,7 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); #endif }; @@ -309,6 +388,7 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); #endif }; @@ -335,6 +415,7 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); #endif }; @@ -361,6 +442,7 @@ public: #ifndef BOOST_LOG_DOXYGEN_PASS static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line); + static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr); static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr); #endif }; |