]> git.lyx.org Git - lyx.git/blob - src/boost.C
minimal effort implementation of:
[lyx.git] / src / boost.C
1 /**
2  * \file boost.C
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_main.h"
14 #include "debug.h"
15 #include "support/lyxlib.h"
16
17 #include <boost/assert.hpp>
18
19 #include <exception>
20
21 using std::endl;
22
23 namespace boost {
24
25 #ifndef BOOST_NO_EXCEPTIONS
26 void throw_exception(std::exception const & e)
27 {
28         lyxerr << "Exception caught:\n"
29             << e.what() << endl;
30         BOOST_ASSERT(false);
31 }
32 #endif
33
34 namespace {
35
36 void emergencyCleanup()
37 {
38         static bool didCleanup;
39         if (didCleanup)
40                 return;
41
42         didCleanup = true;
43
44         LyX::cref().emergencyCleanup();
45 }
46
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
61 }