123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469 |
- /*
- * Copyright Andrey Semashev 2007 - 2015.
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or copy at
- * http://www.boost.org/LICENSE_1_0.txt)
- */
- /*!
- * \file
- * \author Andrey Semashev
- * \date 31.10.2009
- *
- * The header contains exception classes declarations.
- */
- #ifndef BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
- #define BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
- #include <cstddef>
- #include <string>
- #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>
- #ifdef BOOST_HAS_PRAGMA_ONCE
- #pragma once
- #endif
- namespace boost {
- // Forward-declaration of an exception base class from Boost.Exception
- #if defined(__GNUC__)
- # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
- # pragma GCC visibility push (default)
- class exception;
- # pragma GCC visibility pop
- # else
- class exception;
- # endif
- #else
- class BOOST_SYMBOL_VISIBLE exception;
- #endif
- BOOST_LOG_OPEN_NAMESPACE
- namespace aux {
- //! Attaches attribute name exception information
- BOOST_LOG_API void attach_attribute_name_info(exception& e, attribute_name const& name);
- } // 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() BOOST_OVERRIDE;
- /*!
- * Error message accessor.
- */
- const char* what() const throw() BOOST_OVERRIDE;
- #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() BOOST_OVERRIDE;
- #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
- * be caused by the user's code that interacts with the library, such as
- * errors caused by input data.
- */
- class BOOST_LOG_API runtime_error :
- public std::runtime_error
- {
- public:
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit runtime_error(std::string const& descr);
- /*!
- * Destructor
- */
- ~runtime_error() throw() BOOST_OVERRIDE;
- };
- /*!
- * \brief Exception class that is used to indicate errors of missing values
- */
- class BOOST_LOG_API missing_value :
- public runtime_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- missing_value();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit missing_value(std::string const& descr);
- /*!
- * Destructor
- */
- ~missing_value() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate errors of incorrect type of an object
- */
- class BOOST_LOG_API invalid_type :
- public runtime_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- invalid_type();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit invalid_type(std::string const& descr);
- /*!
- * Destructor
- */
- ~invalid_type() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate errors of incorrect value of an object
- */
- class BOOST_LOG_API invalid_value :
- public runtime_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- invalid_value();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit invalid_value(std::string const& descr);
- /*!
- * Destructor
- */
- ~invalid_value() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate parsing errors
- */
- class BOOST_LOG_API parse_error :
- public runtime_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- parse_error();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit parse_error(std::string const& descr);
- /*!
- * Destructor
- */
- ~parse_error() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate conversion errors
- */
- class BOOST_LOG_API conversion_error :
- public runtime_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- conversion_error();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit conversion_error(std::string const& descr);
- /*!
- * Destructor
- */
- ~conversion_error() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate underlying OS API errors
- */
- class BOOST_LOG_API system_error :
- public boost::system::system_error
- {
- public:
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- system_error(boost::system::error_code code, std::string const& descr);
- /*!
- * Destructor
- */
- ~system_error() throw() BOOST_OVERRIDE;
- #ifndef BOOST_LOG_DOXYGEN_PASS
- 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
- };
- /*!
- * \brief Base class for logic exceptions from the logging library
- *
- * Exceptions derived from this class usually indicate errors on the user's side, such as
- * incorrect library usage.
- */
- class BOOST_LOG_API logic_error :
- public std::logic_error
- {
- public:
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit logic_error(std::string const& descr);
- /*!
- * Destructor
- */
- ~logic_error() throw() BOOST_OVERRIDE;
- #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 Exception class that is used to indicate ODR violation
- */
- class BOOST_LOG_API odr_violation :
- public logic_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- odr_violation();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit odr_violation(std::string const& descr);
- /*!
- * Destructor
- */
- ~odr_violation() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate invalid call sequence
- */
- class BOOST_LOG_API unexpected_call :
- public logic_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- unexpected_call();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit unexpected_call(std::string const& descr);
- /*!
- * Destructor
- */
- ~unexpected_call() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate invalid library setup
- */
- class BOOST_LOG_API setup_error :
- public logic_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- setup_error();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit setup_error(std::string const& descr);
- /*!
- * Destructor
- */
- ~setup_error() throw() BOOST_OVERRIDE;
- #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
- };
- /*!
- * \brief Exception class that is used to indicate library limitation
- */
- class BOOST_LOG_API limitation_error :
- public logic_error
- {
- public:
- /*!
- * Default constructor. Creates an exception with the default error message.
- */
- limitation_error();
- /*!
- * Initializing constructor. Creates an exception with the specified error message.
- */
- explicit limitation_error(std::string const& descr);
- /*!
- * Destructor
- */
- ~limitation_error() throw() BOOST_OVERRIDE;
- #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
- };
- BOOST_LOG_CLOSE_NAMESPACE // namespace log
- } // namespace boost
- #ifndef BOOST_LOG_DOXYGEN_PASS
- #define BOOST_LOG_THROW(ex)\
- ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__))
- #define BOOST_LOG_THROW_DESCR(ex, descr)\
- ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__), descr)
- #define BOOST_LOG_THROW_DESCR_PARAMS(ex, descr, params)\
- ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__), descr, BOOST_PP_SEQ_ENUM(params))
- #endif // BOOST_LOG_DOXYGEN_PASS
- #include <boost/log/detail/footer.hpp>
- #endif // BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
|