Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:29

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file
0009  * \author Andrey Semashev
0010  * \date   31.10.2009
0011  *
0012  * The header contains exception classes declarations.
0013  */
0014 
0015 #ifndef BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
0016 #define BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
0017 
0018 #include <cstddef>
0019 #include <string>
0020 #include <stdexcept>
0021 #include <boost/type_index.hpp>
0022 #include <boost/preprocessor/seq/enum.hpp>
0023 #include <boost/system/error_code.hpp>
0024 #include <boost/system/system_error.hpp>
0025 #include <boost/log/detail/config.hpp>
0026 #include <boost/log/attributes/attribute_name.hpp>
0027 #include <boost/log/detail/header.hpp>
0028 
0029 #ifdef BOOST_HAS_PRAGMA_ONCE
0030 #pragma once
0031 #endif
0032 
0033 namespace boost {
0034 
0035 // Forward-declaration of an exception base class from Boost.Exception
0036 #if defined(__GNUC__)
0037 #   if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
0038 #       pragma GCC visibility push (default)
0039 
0040 class exception;
0041 
0042 #       pragma GCC visibility pop
0043 #   else
0044 
0045 class exception;
0046 
0047 #   endif
0048 #else
0049 
0050 class BOOST_SYMBOL_VISIBLE exception;
0051 
0052 #endif
0053 
0054 BOOST_LOG_OPEN_NAMESPACE
0055 
0056 namespace aux {
0057 
0058 //! Attaches attribute name exception information
0059 BOOST_LOG_API void attach_attribute_name_info(exception& e, attribute_name const& name);
0060 
0061 } // namespace aux
0062 
0063 /*!
0064  * \brief Base class for memory allocation errors
0065  *
0066  * Exceptions derived from this class indicate problems with memory allocation.
0067  */
0068 class BOOST_LOG_API bad_alloc :
0069     public std::bad_alloc
0070 {
0071 private:
0072     std::string m_message;
0073 
0074 public:
0075     /*!
0076      * Initializing constructor. Creates an exception with the specified error message.
0077      */
0078     explicit bad_alloc(const char* descr);
0079     /*!
0080      * Initializing constructor. Creates an exception with the specified error message.
0081      */
0082     explicit bad_alloc(std::string const& descr);
0083     /*!
0084      * Destructor
0085      */
0086     ~bad_alloc() throw() BOOST_OVERRIDE;
0087 
0088     /*!
0089      * Error message accessor.
0090      */
0091     const char* what() const throw() BOOST_OVERRIDE;
0092 
0093 #ifndef BOOST_LOG_DOXYGEN_PASS
0094     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0095     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0096 #endif
0097 };
0098 
0099 /*!
0100  * \brief The exception is used to indicate reaching a storage capacity limit
0101  */
0102 class BOOST_LOG_API capacity_limit_reached :
0103     public bad_alloc
0104 {
0105 public:
0106     /*!
0107      * Initializing constructor. Creates an exception with the specified error message.
0108      */
0109     explicit capacity_limit_reached(const char* descr);
0110     /*!
0111      * Initializing constructor. Creates an exception with the specified error message.
0112      */
0113     explicit capacity_limit_reached(std::string const& descr);
0114     /*!
0115      * Destructor
0116      */
0117     ~capacity_limit_reached() throw() BOOST_OVERRIDE;
0118 
0119 #ifndef BOOST_LOG_DOXYGEN_PASS
0120     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0121     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0122 #endif
0123 };
0124 
0125 /*!
0126  * \brief Base class for runtime exceptions from the logging library
0127  *
0128  * Exceptions derived from this class indicate a problem that may not directly
0129  * be caused by the user's code that interacts with the library, such as
0130  * errors caused by input data.
0131  */
0132 class BOOST_LOG_API runtime_error :
0133     public std::runtime_error
0134 {
0135 public:
0136     /*!
0137      * Initializing constructor. Creates an exception with the specified error message.
0138      */
0139     explicit runtime_error(std::string const& descr);
0140     /*!
0141      * Destructor
0142      */
0143     ~runtime_error() throw() BOOST_OVERRIDE;
0144 };
0145 
0146 /*!
0147  * \brief Exception class that is used to indicate errors of missing values
0148  */
0149 class BOOST_LOG_API missing_value :
0150     public runtime_error
0151 {
0152 public:
0153     /*!
0154      * Default constructor. Creates an exception with the default error message.
0155      */
0156     missing_value();
0157     /*!
0158      * Initializing constructor. Creates an exception with the specified error message.
0159      */
0160     explicit missing_value(std::string const& descr);
0161     /*!
0162      * Destructor
0163      */
0164     ~missing_value() throw() BOOST_OVERRIDE;
0165 
0166 #ifndef BOOST_LOG_DOXYGEN_PASS
0167     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0168     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0169     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0170     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name);
0171     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name);
0172 #endif
0173 };
0174 
0175 /*!
0176  * \brief Exception class that is used to indicate errors of incorrect type of an object
0177  */
0178 class BOOST_LOG_API invalid_type :
0179     public runtime_error
0180 {
0181 public:
0182     /*!
0183      * Default constructor. Creates an exception with the default error message.
0184      */
0185     invalid_type();
0186     /*!
0187      * Initializing constructor. Creates an exception with the specified error message.
0188      */
0189     explicit invalid_type(std::string const& descr);
0190     /*!
0191      * Destructor
0192      */
0193     ~invalid_type() throw() BOOST_OVERRIDE;
0194 
0195 #ifndef BOOST_LOG_DOXYGEN_PASS
0196     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0197     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0198     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0199     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name);
0200     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name);
0201     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, typeindex::type_index const& type);
0202     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, typeindex::type_index const& type);
0203     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);
0204     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);
0205 #endif
0206 };
0207 
0208 /*!
0209  * \brief Exception class that is used to indicate errors of incorrect value of an object
0210  */
0211 class BOOST_LOG_API invalid_value :
0212     public runtime_error
0213 {
0214 public:
0215     /*!
0216      * Default constructor. Creates an exception with the default error message.
0217      */
0218     invalid_value();
0219     /*!
0220      * Initializing constructor. Creates an exception with the specified error message.
0221      */
0222     explicit invalid_value(std::string const& descr);
0223     /*!
0224      * Destructor
0225      */
0226     ~invalid_value() throw() BOOST_OVERRIDE;
0227 
0228 #ifndef BOOST_LOG_DOXYGEN_PASS
0229     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0230     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0231     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0232 #endif
0233 };
0234 
0235 /*!
0236  * \brief Exception class that is used to indicate parsing errors
0237  */
0238 class BOOST_LOG_API parse_error :
0239     public runtime_error
0240 {
0241 public:
0242     /*!
0243      * Default constructor. Creates an exception with the default error message.
0244      */
0245     parse_error();
0246     /*!
0247      * Initializing constructor. Creates an exception with the specified error message.
0248      */
0249     explicit parse_error(std::string const& descr);
0250     /*!
0251      * Destructor
0252      */
0253     ~parse_error() throw() BOOST_OVERRIDE;
0254 
0255 #ifndef BOOST_LOG_DOXYGEN_PASS
0256     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0257     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0258     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0259     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, std::size_t content_line);
0260     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, std::size_t content_line);
0261     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name);
0262     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name);
0263 #endif
0264 };
0265 
0266 /*!
0267  * \brief Exception class that is used to indicate conversion errors
0268  */
0269 class BOOST_LOG_API conversion_error :
0270     public runtime_error
0271 {
0272 public:
0273     /*!
0274      * Default constructor. Creates an exception with the default error message.
0275      */
0276     conversion_error();
0277     /*!
0278      * Initializing constructor. Creates an exception with the specified error message.
0279      */
0280     explicit conversion_error(std::string const& descr);
0281     /*!
0282      * Destructor
0283      */
0284     ~conversion_error() throw() BOOST_OVERRIDE;
0285 
0286 #ifndef BOOST_LOG_DOXYGEN_PASS
0287     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0288     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0289     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0290 #endif
0291 };
0292 
0293 /*!
0294  * \brief Exception class that is used to indicate underlying OS API errors
0295  */
0296 class BOOST_LOG_API system_error :
0297     public boost::system::system_error
0298 {
0299 public:
0300     /*!
0301      * Initializing constructor. Creates an exception with the specified error message.
0302      */
0303     system_error(boost::system::error_code code, std::string const& descr);
0304     /*!
0305      * Destructor
0306      */
0307     ~system_error() throw() BOOST_OVERRIDE;
0308 
0309 #ifndef BOOST_LOG_DOXYGEN_PASS
0310     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, int system_error_code);
0311     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, int system_error_code);
0312     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr, boost::system::error_code code);
0313     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, boost::system::error_code code);
0314 #endif
0315 };
0316 
0317 /*!
0318  * \brief Base class for logic exceptions from the logging library
0319  *
0320  * Exceptions derived from this class usually indicate errors on the user's side, such as
0321  * incorrect library usage.
0322  */
0323 class BOOST_LOG_API logic_error :
0324     public std::logic_error
0325 {
0326 public:
0327     /*!
0328      * Initializing constructor. Creates an exception with the specified error message.
0329      */
0330     explicit logic_error(std::string const& descr);
0331     /*!
0332      * Destructor
0333      */
0334     ~logic_error() throw() BOOST_OVERRIDE;
0335 
0336 #ifndef BOOST_LOG_DOXYGEN_PASS
0337     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0338     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0339 #endif
0340 };
0341 
0342 /*!
0343  * \brief Exception class that is used to indicate ODR violation
0344  */
0345 class BOOST_LOG_API odr_violation :
0346     public logic_error
0347 {
0348 public:
0349     /*!
0350      * Default constructor. Creates an exception with the default error message.
0351      */
0352     odr_violation();
0353     /*!
0354      * Initializing constructor. Creates an exception with the specified error message.
0355      */
0356     explicit odr_violation(std::string const& descr);
0357     /*!
0358      * Destructor
0359      */
0360     ~odr_violation() throw() BOOST_OVERRIDE;
0361 
0362 #ifndef BOOST_LOG_DOXYGEN_PASS
0363     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0364     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0365     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0366 #endif
0367 };
0368 
0369 /*!
0370  * \brief Exception class that is used to indicate invalid call sequence
0371  */
0372 class BOOST_LOG_API unexpected_call :
0373     public logic_error
0374 {
0375 public:
0376     /*!
0377      * Default constructor. Creates an exception with the default error message.
0378      */
0379     unexpected_call();
0380     /*!
0381      * Initializing constructor. Creates an exception with the specified error message.
0382      */
0383     explicit unexpected_call(std::string const& descr);
0384     /*!
0385      * Destructor
0386      */
0387     ~unexpected_call() throw() BOOST_OVERRIDE;
0388 
0389 #ifndef BOOST_LOG_DOXYGEN_PASS
0390     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0391     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0392     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0393 #endif
0394 };
0395 
0396 /*!
0397  * \brief Exception class that is used to indicate invalid library setup
0398  */
0399 class BOOST_LOG_API setup_error :
0400     public logic_error
0401 {
0402 public:
0403     /*!
0404      * Default constructor. Creates an exception with the default error message.
0405      */
0406     setup_error();
0407     /*!
0408      * Initializing constructor. Creates an exception with the specified error message.
0409      */
0410     explicit setup_error(std::string const& descr);
0411     /*!
0412      * Destructor
0413      */
0414     ~setup_error() throw() BOOST_OVERRIDE;
0415 
0416 #ifndef BOOST_LOG_DOXYGEN_PASS
0417     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0418     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0419     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0420 #endif
0421 };
0422 
0423 /*!
0424  * \brief Exception class that is used to indicate library limitation
0425  */
0426 class BOOST_LOG_API limitation_error :
0427     public logic_error
0428 {
0429 public:
0430     /*!
0431      * Default constructor. Creates an exception with the default error message.
0432      */
0433     limitation_error();
0434     /*!
0435      * Initializing constructor. Creates an exception with the specified error message.
0436      */
0437     explicit limitation_error(std::string const& descr);
0438     /*!
0439      * Destructor
0440      */
0441     ~limitation_error() throw() BOOST_OVERRIDE;
0442 
0443 #ifndef BOOST_LOG_DOXYGEN_PASS
0444     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
0445     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, const char* descr);
0446     static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
0447 #endif
0448 };
0449 
0450 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0451 
0452 } // namespace boost
0453 
0454 #ifndef BOOST_LOG_DOXYGEN_PASS
0455 
0456 #define BOOST_LOG_THROW(ex)\
0457     ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__))
0458 
0459 #define BOOST_LOG_THROW_DESCR(ex, descr)\
0460     ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__), descr)
0461 
0462 #define BOOST_LOG_THROW_DESCR_PARAMS(ex, descr, params)\
0463     ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__), descr, BOOST_PP_SEQ_ENUM(params))
0464 
0465 #endif // BOOST_LOG_DOXYGEN_PASS
0466 
0467 #include <boost/log/detail/footer.hpp>
0468 
0469 #endif // BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_