Mir
fatal.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 2 or 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * ---
17  * Fatal error handling - Fatal errors are situations we don't expect to ever
18  * happen and don't have logic to gracefully recover from. The most useful
19  * thing you can do in that situation is abort to get a clean core file and
20  * stack trace to maximize the chances of it being readable.
21  *
22  * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
23  * Alan Griffiths <alan@octopull.co.uk>
24  */
25 
26 #ifndef MIR_FATAL_H_
27 #define MIR_FATAL_H_
28 
29 namespace mir
30 {
38 extern void (*fatal_error)(char const* reason, ...);
39 
45 void fatal_error_except(char const* reason, ...);
46 
52 void fatal_error_abort(char const* reason, ...);
53 
54 // Utility class to override & restore existing error handler
56 {
57 public:
58  explicit FatalErrorStrategy(void (*fatal_error_handler)(char const* reason, ...)) :
59  old_fatal_error_handler(fatal_error)
60  {
61  fatal_error = fatal_error_handler;
62  }
63 
65  {
66  fatal_error = old_fatal_error_handler;
67  }
68 
69 private:
70  void (*old_fatal_error_handler)(char const* reason, ...);
71  FatalErrorStrategy(FatalErrorStrategy const&) = delete;
72  FatalErrorStrategy& operator=(FatalErrorStrategy const&) = delete;
73 };
74 } // namespace mir
75 
76 #endif // MIR_FATAL_H_
Definition: splash_session.h:24
Definition: fatal.h:55
void fatal_error_abort(char const *reason,...)
An alternative to fatal_error_except() that kills the program and dump core as cleanly as possible...
FatalErrorStrategy(void(*fatal_error_handler)(char const *reason,...))
Definition: fatal.h:58
void(* fatal_error)(char const *reason,...)
fatal_error() is strictly for "this should never happen" situations that you cannot recover from...
void fatal_error_except(char const *reason,...)
Throws an exception that will typically kill the Mir server and propagate from mir::run_mir.
~FatalErrorStrategy()
Definition: fatal.h:64

Copyright © 2012-2019 Canonical Ltd.
Generated on Thu Feb 28 09:03:56 UTC 2019
This documentation is licensed under the GPL version 2 or 3.