]> git.lyx.org Git - lyx.git/blob - src/boost.cpp
46d43df40ecdce4667951b3efe45fbe061889f04
[lyx.git] / src / boost.cpp
1 /**
2  * \file boost.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "LyX.h"
14
15 #include "support/debug.h"
16 #include "support/lyxlib.h"
17
18 #include <boost/assert.hpp>
19
20 #include <exception>
21 #include <iomanip>
22
23 using std::endl;
24 using lyx::lyxerr;
25 using lyx::LyX;
26
27 namespace boost {
28
29 #ifndef BOOST_NO_EXCEPTIONS
30 void throw_exception(std::exception const & e)
31 {
32         lyxerr << "Exception caught:\n" << e.what() << endl;
33         BOOST_ASSERT(false);
34 }
35 #endif
36
37
38 void emergencyCleanup()
39 {
40         static bool didCleanup;
41         if (didCleanup)
42                 return;
43
44         didCleanup = true;
45
46         LyX::cref().emergencyCleanup();
47 }
48
49
50 void assertion_failed(char const * expr, char const * function,
51                       char const * file, long line)
52 {
53         lyxerr << "Assertion triggered in " << function
54                << " by failing check \"" << expr << "\""
55                << " in file " << file << ":" << line << endl;
56         emergencyCleanup();
57         lyx::support::abort();
58 }
59
60 } // namespace boost