Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 31.10.2009
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains exception classes declarations.
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <cstddef>
|
Chris@16
|
19 #include <string>
|
Chris@16
|
20 #include <stdexcept>
|
Chris@16
|
21 #include <boost/preprocessor/seq/enum.hpp>
|
Chris@16
|
22 #include <boost/log/detail/config.hpp>
|
Chris@16
|
23 #include <boost/log/attributes/attribute_name.hpp>
|
Chris@16
|
24 #include <boost/log/utility/type_info_wrapper.hpp>
|
Chris@16
|
25 #include <boost/log/detail/header.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
28 #pragma once
|
Chris@16
|
29 #endif
|
Chris@16
|
30
|
Chris@16
|
31 namespace boost {
|
Chris@16
|
32
|
Chris@16
|
33 // Forward-declaration of an exception base class from Boost.Exception
|
Chris@16
|
34 #if defined(__GNUC__)
|
Chris@16
|
35 # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
Chris@16
|
36 # pragma GCC visibility push (default)
|
Chris@16
|
37
|
Chris@16
|
38 class exception;
|
Chris@16
|
39
|
Chris@16
|
40 # pragma GCC visibility pop
|
Chris@16
|
41 # else
|
Chris@16
|
42
|
Chris@16
|
43 class exception;
|
Chris@16
|
44
|
Chris@16
|
45 # endif
|
Chris@16
|
46 #else
|
Chris@16
|
47
|
Chris@16
|
48 class BOOST_SYMBOL_VISIBLE exception;
|
Chris@16
|
49
|
Chris@16
|
50 #endif
|
Chris@16
|
51
|
Chris@16
|
52 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
53
|
Chris@16
|
54 namespace aux {
|
Chris@16
|
55
|
Chris@16
|
56 //! Attaches attribute name exception information
|
Chris@16
|
57 BOOST_LOG_API void attach_attribute_name_info(exception& e, attribute_name const& name);
|
Chris@16
|
58
|
Chris@16
|
59 } // namespace aux
|
Chris@16
|
60
|
Chris@16
|
61 /*!
|
Chris@16
|
62 * \brief Base class for runtime exceptions from the logging library
|
Chris@16
|
63 *
|
Chris@16
|
64 * Exceptions derived from this class indicate a problem that may not directly
|
Chris@16
|
65 * be caused by the user's code that interacts with the library, such as
|
Chris@16
|
66 * errors caused by input data.
|
Chris@16
|
67 */
|
Chris@16
|
68 class BOOST_LOG_API runtime_error :
|
Chris@16
|
69 public std::runtime_error
|
Chris@16
|
70 {
|
Chris@16
|
71 protected:
|
Chris@16
|
72 /*!
|
Chris@16
|
73 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
74 */
|
Chris@16
|
75 explicit runtime_error(std::string const& descr);
|
Chris@16
|
76 /*!
|
Chris@16
|
77 * Destructor
|
Chris@16
|
78 */
|
Chris@16
|
79 ~runtime_error() throw();
|
Chris@16
|
80 };
|
Chris@16
|
81
|
Chris@16
|
82 /*!
|
Chris@16
|
83 * \brief Exception class that is used to indicate errors of missing values
|
Chris@16
|
84 */
|
Chris@16
|
85 class BOOST_LOG_API missing_value :
|
Chris@16
|
86 public runtime_error
|
Chris@16
|
87 {
|
Chris@16
|
88 public:
|
Chris@16
|
89 /*!
|
Chris@16
|
90 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
91 */
|
Chris@16
|
92 missing_value();
|
Chris@16
|
93 /*!
|
Chris@16
|
94 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
95 */
|
Chris@16
|
96 explicit missing_value(std::string const& descr);
|
Chris@16
|
97 /*!
|
Chris@16
|
98 * Destructor
|
Chris@16
|
99 */
|
Chris@16
|
100 ~missing_value() throw();
|
Chris@16
|
101
|
Chris@16
|
102 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
103 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
104 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
105 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name);
|
Chris@16
|
106 #endif
|
Chris@16
|
107 };
|
Chris@16
|
108
|
Chris@16
|
109 /*!
|
Chris@16
|
110 * \brief Exception class that is used to indicate errors of incorrect type of an object
|
Chris@16
|
111 */
|
Chris@16
|
112 class BOOST_LOG_API invalid_type :
|
Chris@16
|
113 public runtime_error
|
Chris@16
|
114 {
|
Chris@16
|
115 public:
|
Chris@16
|
116 /*!
|
Chris@16
|
117 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
118 */
|
Chris@16
|
119 invalid_type();
|
Chris@16
|
120 /*!
|
Chris@16
|
121 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
122 */
|
Chris@16
|
123 explicit invalid_type(std::string const& descr);
|
Chris@16
|
124 /*!
|
Chris@16
|
125 * Destructor
|
Chris@16
|
126 */
|
Chris@16
|
127 ~invalid_type() throw();
|
Chris@16
|
128
|
Chris@16
|
129 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
130 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
131 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
132 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name);
|
Chris@16
|
133 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, type_info_wrapper const& type);
|
Chris@16
|
134 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
|
135 #endif
|
Chris@16
|
136 };
|
Chris@16
|
137
|
Chris@16
|
138 /*!
|
Chris@16
|
139 * \brief Exception class that is used to indicate errors of incorrect value of an object
|
Chris@16
|
140 */
|
Chris@16
|
141 class BOOST_LOG_API invalid_value :
|
Chris@16
|
142 public runtime_error
|
Chris@16
|
143 {
|
Chris@16
|
144 public:
|
Chris@16
|
145 /*!
|
Chris@16
|
146 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
147 */
|
Chris@16
|
148 invalid_value();
|
Chris@16
|
149 /*!
|
Chris@16
|
150 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
151 */
|
Chris@16
|
152 explicit invalid_value(std::string const& descr);
|
Chris@16
|
153 /*!
|
Chris@16
|
154 * Destructor
|
Chris@16
|
155 */
|
Chris@16
|
156 ~invalid_value() throw();
|
Chris@16
|
157
|
Chris@16
|
158 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
159 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
160 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
161 #endif
|
Chris@16
|
162 };
|
Chris@16
|
163
|
Chris@16
|
164 /*!
|
Chris@16
|
165 * \brief Exception class that is used to indicate parsing errors
|
Chris@16
|
166 */
|
Chris@16
|
167 class BOOST_LOG_API parse_error :
|
Chris@16
|
168 public runtime_error
|
Chris@16
|
169 {
|
Chris@16
|
170 public:
|
Chris@16
|
171 /*!
|
Chris@16
|
172 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
173 */
|
Chris@16
|
174 parse_error();
|
Chris@16
|
175 /*!
|
Chris@16
|
176 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
177 */
|
Chris@16
|
178 explicit parse_error(std::string const& descr);
|
Chris@16
|
179 /*!
|
Chris@16
|
180 * Destructor
|
Chris@16
|
181 */
|
Chris@16
|
182 ~parse_error() throw();
|
Chris@16
|
183
|
Chris@16
|
184 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
185 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
186 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
187 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, std::size_t content_line);
|
Chris@16
|
188 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name);
|
Chris@16
|
189 #endif
|
Chris@16
|
190 };
|
Chris@16
|
191
|
Chris@16
|
192 /*!
|
Chris@16
|
193 * \brief Exception class that is used to indicate conversion errors
|
Chris@16
|
194 */
|
Chris@16
|
195 class BOOST_LOG_API conversion_error :
|
Chris@16
|
196 public runtime_error
|
Chris@16
|
197 {
|
Chris@16
|
198 public:
|
Chris@16
|
199 /*!
|
Chris@16
|
200 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
201 */
|
Chris@16
|
202 conversion_error();
|
Chris@16
|
203 /*!
|
Chris@16
|
204 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
205 */
|
Chris@16
|
206 explicit conversion_error(std::string const& descr);
|
Chris@16
|
207 /*!
|
Chris@16
|
208 * Destructor
|
Chris@16
|
209 */
|
Chris@16
|
210 ~conversion_error() throw();
|
Chris@16
|
211
|
Chris@16
|
212 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
213 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
214 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
215 #endif
|
Chris@16
|
216 };
|
Chris@16
|
217
|
Chris@16
|
218 /*!
|
Chris@16
|
219 * \brief Exception class that is used to indicate underlying OS API errors
|
Chris@16
|
220 */
|
Chris@16
|
221 class BOOST_LOG_API system_error :
|
Chris@16
|
222 public runtime_error
|
Chris@16
|
223 {
|
Chris@16
|
224 public:
|
Chris@16
|
225 /*!
|
Chris@16
|
226 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
227 */
|
Chris@16
|
228 system_error();
|
Chris@16
|
229 /*!
|
Chris@16
|
230 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
231 */
|
Chris@16
|
232 explicit system_error(std::string const& descr);
|
Chris@16
|
233 /*!
|
Chris@16
|
234 * Destructor
|
Chris@16
|
235 */
|
Chris@16
|
236 ~system_error() throw();
|
Chris@16
|
237
|
Chris@16
|
238 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
239 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
240 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
241 #endif
|
Chris@16
|
242 };
|
Chris@16
|
243
|
Chris@16
|
244 /*!
|
Chris@16
|
245 * \brief Base class for logic exceptions from the logging library
|
Chris@16
|
246 *
|
Chris@16
|
247 * Exceptions derived from this class usually indicate errors on the user's side, such as
|
Chris@16
|
248 * incorrect library usage.
|
Chris@16
|
249 */
|
Chris@16
|
250 class BOOST_LOG_API logic_error :
|
Chris@16
|
251 public std::logic_error
|
Chris@16
|
252 {
|
Chris@16
|
253 protected:
|
Chris@16
|
254 /*!
|
Chris@16
|
255 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
256 */
|
Chris@16
|
257 explicit logic_error(std::string const& descr);
|
Chris@16
|
258 /*!
|
Chris@16
|
259 * Destructor
|
Chris@16
|
260 */
|
Chris@16
|
261 ~logic_error() throw();
|
Chris@16
|
262 };
|
Chris@16
|
263
|
Chris@16
|
264 /*!
|
Chris@16
|
265 * \brief Exception class that is used to indicate ODR violation
|
Chris@16
|
266 */
|
Chris@16
|
267 class BOOST_LOG_API odr_violation :
|
Chris@16
|
268 public logic_error
|
Chris@16
|
269 {
|
Chris@16
|
270 public:
|
Chris@16
|
271 /*!
|
Chris@16
|
272 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
273 */
|
Chris@16
|
274 odr_violation();
|
Chris@16
|
275 /*!
|
Chris@16
|
276 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
277 */
|
Chris@16
|
278 explicit odr_violation(std::string const& descr);
|
Chris@16
|
279 /*!
|
Chris@16
|
280 * Destructor
|
Chris@16
|
281 */
|
Chris@16
|
282 ~odr_violation() throw();
|
Chris@16
|
283
|
Chris@16
|
284 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
285 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
286 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
287 #endif
|
Chris@16
|
288 };
|
Chris@16
|
289
|
Chris@16
|
290 /*!
|
Chris@16
|
291 * \brief Exception class that is used to indicate invalid call sequence
|
Chris@16
|
292 */
|
Chris@16
|
293 class BOOST_LOG_API unexpected_call :
|
Chris@16
|
294 public logic_error
|
Chris@16
|
295 {
|
Chris@16
|
296 public:
|
Chris@16
|
297 /*!
|
Chris@16
|
298 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
299 */
|
Chris@16
|
300 unexpected_call();
|
Chris@16
|
301 /*!
|
Chris@16
|
302 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
303 */
|
Chris@16
|
304 explicit unexpected_call(std::string const& descr);
|
Chris@16
|
305 /*!
|
Chris@16
|
306 * Destructor
|
Chris@16
|
307 */
|
Chris@16
|
308 ~unexpected_call() throw();
|
Chris@16
|
309
|
Chris@16
|
310 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
311 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
312 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
313 #endif
|
Chris@16
|
314 };
|
Chris@16
|
315
|
Chris@16
|
316 /*!
|
Chris@16
|
317 * \brief Exception class that is used to indicate invalid library setup
|
Chris@16
|
318 */
|
Chris@16
|
319 class BOOST_LOG_API setup_error :
|
Chris@16
|
320 public logic_error
|
Chris@16
|
321 {
|
Chris@16
|
322 public:
|
Chris@16
|
323 /*!
|
Chris@16
|
324 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
325 */
|
Chris@16
|
326 setup_error();
|
Chris@16
|
327 /*!
|
Chris@16
|
328 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
329 */
|
Chris@16
|
330 explicit setup_error(std::string const& descr);
|
Chris@16
|
331 /*!
|
Chris@16
|
332 * Destructor
|
Chris@16
|
333 */
|
Chris@16
|
334 ~setup_error() throw();
|
Chris@16
|
335
|
Chris@16
|
336 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
337 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
338 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
339 #endif
|
Chris@16
|
340 };
|
Chris@16
|
341
|
Chris@16
|
342 /*!
|
Chris@16
|
343 * \brief Exception class that is used to indicate library limitation
|
Chris@16
|
344 */
|
Chris@16
|
345 class BOOST_LOG_API limitation_error :
|
Chris@16
|
346 public logic_error
|
Chris@16
|
347 {
|
Chris@16
|
348 public:
|
Chris@16
|
349 /*!
|
Chris@16
|
350 * Default constructor. Creates an exception with the default error message.
|
Chris@16
|
351 */
|
Chris@16
|
352 limitation_error();
|
Chris@16
|
353 /*!
|
Chris@16
|
354 * Initializing constructor. Creates an exception with the specified error message.
|
Chris@16
|
355 */
|
Chris@16
|
356 explicit limitation_error(std::string const& descr);
|
Chris@16
|
357 /*!
|
Chris@16
|
358 * Destructor
|
Chris@16
|
359 */
|
Chris@16
|
360 ~limitation_error() throw();
|
Chris@16
|
361
|
Chris@16
|
362 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
363 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line);
|
Chris@16
|
364 static BOOST_LOG_NORETURN void throw_(const char* file, std::size_t line, std::string const& descr);
|
Chris@16
|
365 #endif
|
Chris@16
|
366 };
|
Chris@16
|
367
|
Chris@16
|
368 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
369
|
Chris@16
|
370 } // namespace boost
|
Chris@16
|
371
|
Chris@16
|
372 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
373
|
Chris@16
|
374 #define BOOST_LOG_THROW(ex)\
|
Chris@16
|
375 ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__))
|
Chris@16
|
376
|
Chris@16
|
377 #define BOOST_LOG_THROW_DESCR(ex, descr)\
|
Chris@16
|
378 ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__), descr)
|
Chris@16
|
379
|
Chris@16
|
380 #define BOOST_LOG_THROW_DESCR_PARAMS(ex, descr, params)\
|
Chris@16
|
381 ex::throw_(__FILE__, static_cast< std::size_t >(__LINE__), descr, BOOST_PP_SEQ_ENUM(params))
|
Chris@16
|
382
|
Chris@16
|
383 #endif // BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
384
|
Chris@16
|
385 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
386
|
Chris@16
|
387 #endif // BOOST_LOG_EXCEPTIONS_HPP_INCLUDED_
|