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