1/*
2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7/*!
8 * \file exceptions.cpp
9 * \author Andrey Semashev
10 * \date 31.10.2009
11 *
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
14 */
15
16#include <boost/log/detail/config.hpp>
17#include <boost/throw_exception.hpp>
18#include <boost/exception/exception.hpp>
19#include <boost/exception/errinfo_at_line.hpp>
20#include <boost/exception/info.hpp>
21#include <boost/log/exceptions.hpp>
22#include <boost/log/support/exception.hpp>
23#include <boost/log/detail/header.hpp>
24
25#ifdef _MSC_VER
26#pragma warning(push)
27// conversion from 'size_t' to 'boost::error_info<boost::throw_line_,int>::value_type', possible loss of data
28// No idea why line number is stored as a signed integer in the error info...
29#pragma warning(disable: 4267)
30#endif
31
32namespace boost {
33
34BOOST_LOG_OPEN_NAMESPACE
35
36namespace aux {
37
38//! Attaches attribute name exception information
39BOOST_LOG_API void attach_attribute_name_info(exception& e, attribute_name const& name)
40{
41 e << attribute_name_info(name);
42}
43
44} // namespace aux
45
46bad_alloc::bad_alloc(const char* descr) :
47 m_message(descr)
48{
49}
50
51bad_alloc::bad_alloc(std::string const& descr) :
52 m_message(descr)
53{
54}
55
56bad_alloc::~bad_alloc() throw()
57{
58}
59
60const char* bad_alloc::what() const throw()
61{
62 return m_message.c_str();
63}
64
65void bad_alloc::throw_(const char* file, std::size_t line, const char* descr)
66{
67 boost::throw_exception(e: boost::enable_error_info(x: bad_alloc(descr))
68 << boost::throw_file(file)
69 << boost::throw_line(line)
70 );
71}
72
73void bad_alloc::throw_(const char* file, std::size_t line, std::string const& descr)
74{
75 boost::throw_exception(e: boost::enable_error_info(x: bad_alloc(descr))
76 << boost::throw_file(file)
77 << boost::throw_line(line)
78 );
79}
80
81capacity_limit_reached::capacity_limit_reached(const char* descr) :
82 bad_alloc(descr)
83{
84}
85
86capacity_limit_reached::capacity_limit_reached(std::string const& descr) :
87 bad_alloc(descr)
88{
89}
90
91capacity_limit_reached::~capacity_limit_reached() throw()
92{
93}
94
95void capacity_limit_reached::throw_(const char* file, std::size_t line, const char* descr)
96{
97 boost::throw_exception(e: boost::enable_error_info(x: capacity_limit_reached(descr))
98 << boost::throw_file(file)
99 << boost::throw_line(line)
100 );
101}
102
103void capacity_limit_reached::throw_(const char* file, std::size_t line, std::string const& descr)
104{
105 boost::throw_exception(e: boost::enable_error_info(x: capacity_limit_reached(descr))
106 << boost::throw_file(file)
107 << boost::throw_line(line)
108 );
109}
110
111runtime_error::runtime_error(std::string const& descr) :
112 std::runtime_error(descr)
113{
114}
115
116runtime_error::~runtime_error() throw()
117{
118}
119
120missing_value::missing_value() :
121 runtime_error("Requested value not found")
122{
123}
124
125missing_value::missing_value(std::string const& descr) :
126 runtime_error(descr)
127{
128}
129
130missing_value::~missing_value() throw()
131{
132}
133
134void missing_value::throw_(const char* file, std::size_t line)
135{
136 boost::throw_exception(e: boost::enable_error_info(x: missing_value())
137 << boost::throw_file(file)
138 << boost::throw_line(line)
139 );
140}
141
142void missing_value::throw_(const char* file, std::size_t line, const char* descr)
143{
144 boost::throw_exception(e: boost::enable_error_info(x: missing_value(descr))
145 << boost::throw_file(file)
146 << boost::throw_line(line)
147 );
148}
149
150void missing_value::throw_(const char* file, std::size_t line, std::string const& descr)
151{
152 boost::throw_exception(e: boost::enable_error_info(x: missing_value(descr))
153 << boost::throw_file(file)
154 << boost::throw_line(line)
155 );
156}
157
158void missing_value::throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name)
159{
160 boost::throw_exception(e: boost::enable_error_info(x: missing_value(descr))
161 << boost::throw_file(file)
162 << boost::throw_line(line)
163 << attribute_name_info(name)
164 );
165}
166
167void missing_value::throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name)
168{
169 boost::throw_exception(e: boost::enable_error_info(x: missing_value(descr))
170 << boost::throw_file(file)
171 << boost::throw_line(line)
172 << attribute_name_info(name)
173 );
174}
175
176invalid_type::invalid_type() :
177 runtime_error("Requested value has invalid type")
178{
179}
180
181invalid_type::invalid_type(std::string const& descr) :
182 runtime_error(descr)
183{
184}
185
186invalid_type::~invalid_type() throw()
187{
188}
189
190void invalid_type::throw_(const char* file, std::size_t line)
191{
192 boost::throw_exception(e: boost::enable_error_info(x: invalid_type())
193 << boost::throw_file(file)
194 << boost::throw_line(line)
195 );
196}
197
198void invalid_type::throw_(const char* file, std::size_t line, const char* descr)
199{
200 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
201 << boost::throw_file(file)
202 << boost::throw_line(line)
203 );
204}
205
206void invalid_type::throw_(const char* file, std::size_t line, std::string const& descr)
207{
208 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
209 << boost::throw_file(file)
210 << boost::throw_line(line)
211 );
212}
213
214void invalid_type::throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name)
215{
216 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
217 << boost::throw_file(file)
218 << boost::throw_line(line)
219 << attribute_name_info(name)
220 );
221}
222
223void invalid_type::throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name)
224{
225 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
226 << boost::throw_file(file)
227 << boost::throw_line(line)
228 << attribute_name_info(name)
229 );
230}
231
232void invalid_type::throw_(const char* file, std::size_t line, const char* descr, typeindex::type_index const& type)
233{
234 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
235 << boost::throw_file(file)
236 << boost::throw_line(line)
237 << type_info_info(type)
238 );
239}
240
241void invalid_type::throw_(const char* file, std::size_t line, std::string const& descr, typeindex::type_index const& type)
242{
243 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
244 << boost::throw_file(file)
245 << boost::throw_line(line)
246 << type_info_info(type)
247 );
248}
249
250void invalid_type::throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name, typeindex::type_index const& type)
251{
252 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
253 << boost::throw_file(file)
254 << boost::throw_line(line)
255 << attribute_name_info(name)
256 << type_info_info(type)
257 );
258}
259
260void invalid_type::throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name, typeindex::type_index const& type)
261{
262 boost::throw_exception(e: boost::enable_error_info(x: invalid_type(descr))
263 << boost::throw_file(file)
264 << boost::throw_line(line)
265 << attribute_name_info(name)
266 << type_info_info(type)
267 );
268}
269
270invalid_value::invalid_value() :
271 runtime_error("The value is invalid")
272{
273}
274
275invalid_value::invalid_value(std::string const& descr) :
276 runtime_error(descr)
277{
278}
279
280invalid_value::~invalid_value() throw()
281{
282}
283
284void invalid_value::throw_(const char* file, std::size_t line)
285{
286 boost::throw_exception(e: boost::enable_error_info(x: invalid_value())
287 << boost::throw_file(file)
288 << boost::throw_line(line)
289 );
290}
291
292void invalid_value::throw_(const char* file, std::size_t line, const char* descr)
293{
294 boost::throw_exception(e: boost::enable_error_info(x: invalid_value(descr))
295 << boost::throw_file(file)
296 << boost::throw_line(line)
297 );
298}
299
300void invalid_value::throw_(const char* file, std::size_t line, std::string const& descr)
301{
302 boost::throw_exception(e: boost::enable_error_info(x: invalid_value(descr))
303 << boost::throw_file(file)
304 << boost::throw_line(line)
305 );
306}
307
308parse_error::parse_error() :
309 runtime_error("Failed to parse content")
310{
311}
312
313parse_error::parse_error(std::string const& descr) :
314 runtime_error(descr)
315{
316}
317
318parse_error::~parse_error() throw()
319{
320}
321
322void parse_error::throw_(const char* file, std::size_t line)
323{
324 boost::throw_exception(e: boost::enable_error_info(x: parse_error())
325 << boost::throw_file(file)
326 << boost::throw_line(line)
327 );
328}
329
330void parse_error::throw_(const char* file, std::size_t line, const char* descr)
331{
332 boost::throw_exception(e: boost::enable_error_info(x: parse_error(descr))
333 << boost::throw_file(file)
334 << boost::throw_line(line)
335 );
336}
337
338void parse_error::throw_(const char* file, std::size_t line, std::string const& descr)
339{
340 boost::throw_exception(e: boost::enable_error_info(x: parse_error(descr))
341 << boost::throw_file(file)
342 << boost::throw_line(line)
343 );
344}
345
346void parse_error::throw_(const char* file, std::size_t line, const char* descr, std::size_t content_line)
347{
348 boost::throw_exception(e: boost::enable_error_info(x: parse_error(descr))
349 << boost::throw_file(file)
350 << boost::throw_line(line)
351 << boost::errinfo_at_line(content_line)
352 );
353}
354
355void parse_error::throw_(const char* file, std::size_t line, std::string const& descr, std::size_t content_line)
356{
357 boost::throw_exception(e: boost::enable_error_info(x: parse_error(descr))
358 << boost::throw_file(file)
359 << boost::throw_line(line)
360 << boost::errinfo_at_line(content_line)
361 );
362}
363
364void parse_error::throw_(const char* file, std::size_t line, const char* descr, attribute_name const& name)
365{
366 boost::throw_exception(e: boost::enable_error_info(x: parse_error(descr))
367 << boost::throw_file(file)
368 << boost::throw_line(line)
369 << attribute_name_info(name)
370 );
371}
372
373void parse_error::throw_(const char* file, std::size_t line, std::string const& descr, attribute_name const& name)
374{
375 boost::throw_exception(e: boost::enable_error_info(x: parse_error(descr))
376 << boost::throw_file(file)
377 << boost::throw_line(line)
378 << attribute_name_info(name)
379 );
380}
381
382conversion_error::conversion_error() :
383 runtime_error("Failed to perform conversion")
384{
385}
386
387conversion_error::conversion_error(std::string const& descr) :
388 runtime_error(descr)
389{
390}
391
392conversion_error::~conversion_error() throw()
393{
394}
395
396void conversion_error::throw_(const char* file, std::size_t line)
397{
398 boost::throw_exception(e: boost::enable_error_info(x: conversion_error())
399 << boost::throw_file(file)
400 << boost::throw_line(line)
401 );
402}
403
404void conversion_error::throw_(const char* file, std::size_t line, const char* descr)
405{
406 boost::throw_exception(e: boost::enable_error_info(x: conversion_error(descr))
407 << boost::throw_file(file)
408 << boost::throw_line(line)
409 );
410}
411
412void conversion_error::throw_(const char* file, std::size_t line, std::string const& descr)
413{
414 boost::throw_exception(e: boost::enable_error_info(x: conversion_error(descr))
415 << boost::throw_file(file)
416 << boost::throw_line(line)
417 );
418}
419
420system_error::system_error(boost::system::error_code code, std::string const& descr) :
421 boost::system::system_error(code, descr)
422{
423}
424
425system_error::~system_error() throw()
426{
427}
428
429void system_error::throw_(const char* file, std::size_t line, const char* descr, int system_error_code)
430{
431 boost::throw_exception(e: boost::enable_error_info(x: system_error(boost::system::error_code(system_error_code, boost::system::system_category()), descr))
432 << boost::throw_file(file)
433 << boost::throw_line(line)
434 );
435}
436
437void system_error::throw_(const char* file, std::size_t line, std::string const& descr, int system_error_code)
438{
439 boost::throw_exception(e: boost::enable_error_info(x: system_error(boost::system::error_code(system_error_code, boost::system::system_category()), descr))
440 << boost::throw_file(file)
441 << boost::throw_line(line)
442 );
443}
444
445void system_error::throw_(const char* file, std::size_t line, const char* descr, boost::system::error_code code)
446{
447 boost::throw_exception(e: boost::enable_error_info(x: system_error(code, descr))
448 << boost::throw_file(file)
449 << boost::throw_line(line)
450 );
451}
452
453void system_error::throw_(const char* file, std::size_t line, std::string const& descr, boost::system::error_code code)
454{
455 boost::throw_exception(e: boost::enable_error_info(x: system_error(code, descr))
456 << boost::throw_file(file)
457 << boost::throw_line(line)
458 );
459}
460
461logic_error::logic_error(std::string const& descr) :
462 std::logic_error(descr)
463{
464}
465
466logic_error::~logic_error() throw()
467{
468}
469
470void logic_error::throw_(const char* file, std::size_t line, const char* descr)
471{
472 boost::throw_exception(e: boost::enable_error_info(x: logic_error(descr))
473 << boost::throw_file(file)
474 << boost::throw_line(line)
475 );
476}
477
478void logic_error::throw_(const char* file, std::size_t line, std::string const& descr)
479{
480 boost::throw_exception(e: boost::enable_error_info(x: logic_error(descr))
481 << boost::throw_file(file)
482 << boost::throw_line(line)
483 );
484}
485
486odr_violation::odr_violation() :
487 logic_error("ODR violation detected")
488{
489}
490
491odr_violation::odr_violation(std::string const& descr) :
492 logic_error(descr)
493{
494}
495
496odr_violation::~odr_violation() throw()
497{
498}
499
500void odr_violation::throw_(const char* file, std::size_t line)
501{
502 boost::throw_exception(e: boost::enable_error_info(x: odr_violation())
503 << boost::throw_file(file)
504 << boost::throw_line(line)
505 );
506}
507
508void odr_violation::throw_(const char* file, std::size_t line, const char* descr)
509{
510 boost::throw_exception(e: boost::enable_error_info(x: odr_violation(descr))
511 << boost::throw_file(file)
512 << boost::throw_line(line)
513 );
514}
515
516void odr_violation::throw_(const char* file, std::size_t line, std::string const& descr)
517{
518 boost::throw_exception(e: boost::enable_error_info(x: odr_violation(descr))
519 << boost::throw_file(file)
520 << boost::throw_line(line)
521 );
522}
523
524unexpected_call::unexpected_call() :
525 logic_error("Invalid call sequence")
526{
527}
528
529unexpected_call::unexpected_call(std::string const& descr) :
530 logic_error(descr)
531{
532}
533
534unexpected_call::~unexpected_call() throw()
535{
536}
537
538void unexpected_call::throw_(const char* file, std::size_t line)
539{
540 boost::throw_exception(e: boost::enable_error_info(x: unexpected_call())
541 << boost::throw_file(file)
542 << boost::throw_line(line)
543 );
544}
545
546void unexpected_call::throw_(const char* file, std::size_t line, const char* descr)
547{
548 boost::throw_exception(e: boost::enable_error_info(x: unexpected_call(descr))
549 << boost::throw_file(file)
550 << boost::throw_line(line)
551 );
552}
553
554void unexpected_call::throw_(const char* file, std::size_t line, std::string const& descr)
555{
556 boost::throw_exception(e: boost::enable_error_info(x: unexpected_call(descr))
557 << boost::throw_file(file)
558 << boost::throw_line(line)
559 );
560}
561
562setup_error::setup_error() :
563 logic_error("The library is not initialized properly")
564{
565}
566
567setup_error::setup_error(std::string const& descr) :
568 logic_error(descr)
569{
570}
571
572setup_error::~setup_error() throw()
573{
574}
575
576void setup_error::throw_(const char* file, std::size_t line)
577{
578 boost::throw_exception(e: boost::enable_error_info(x: setup_error())
579 << boost::throw_file(file)
580 << boost::throw_line(line)
581 );
582}
583
584void setup_error::throw_(const char* file, std::size_t line, const char* descr)
585{
586 boost::throw_exception(e: boost::enable_error_info(x: setup_error(descr))
587 << boost::throw_file(file)
588 << boost::throw_line(line)
589 );
590}
591
592void setup_error::throw_(const char* file, std::size_t line, std::string const& descr)
593{
594 boost::throw_exception(e: boost::enable_error_info(x: setup_error(descr))
595 << boost::throw_file(file)
596 << boost::throw_line(line)
597 );
598}
599
600limitation_error::limitation_error() :
601 logic_error("Boost.Log library limit reached")
602{
603}
604
605limitation_error::limitation_error(std::string const& descr) :
606 logic_error(descr)
607{
608}
609
610limitation_error::~limitation_error() throw()
611{
612}
613
614void limitation_error::throw_(const char* file, std::size_t line)
615{
616 boost::throw_exception(e: boost::enable_error_info(x: limitation_error())
617 << boost::throw_file(file)
618 << boost::throw_line(line)
619 );
620}
621
622void limitation_error::throw_(const char* file, std::size_t line, const char* descr)
623{
624 boost::throw_exception(e: boost::enable_error_info(x: limitation_error(descr))
625 << boost::throw_file(file)
626 << boost::throw_line(line)
627 );
628}
629
630void limitation_error::throw_(const char* file, std::size_t line, std::string const& descr)
631{
632 boost::throw_exception(e: boost::enable_error_info(x: limitation_error(descr))
633 << boost::throw_file(file)
634 << boost::throw_line(line)
635 );
636}
637
638BOOST_LOG_CLOSE_NAMESPACE // namespace log
639
640} // namespace boost
641
642#ifdef _MSC_VER
643#pragma warning(pop)
644#endif
645
646#include <boost/log/detail/footer.hpp>
647

source code of boost/libs/log/src/exceptions.cpp