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
29namespace mir
30{
40extern void (*fatal_error)(char const* reason, ...);
41
47void fatal_error_except(char const* reason, ...);
48
54void fatal_error_abort(char const* reason, ...);
55
56// Utility class to override & restore existing error handler
58{
59public:
60 explicit FatalErrorStrategy(void (*fatal_error_handler)(char const* reason, ...)) :
61 old_fatal_error_handler(fatal_error)
62 {
63 fatal_error = fatal_error_handler;
64 }
65
67 {
68 fatal_error = old_fatal_error_handler;
69 }
70
71private:
72 void (*old_fatal_error_handler)(char const* reason, ...);
74 FatalErrorStrategy& operator=(FatalErrorStrategy const&) = delete;
75};
76} // namespace mir
77
78#endif // MIR_FATAL_H_
Definition: fatal.h:58
FatalErrorStrategy(void(*fatal_error_handler)(char const *reason,...))
Definition: fatal.h:60
~FatalErrorStrategy()
Definition: fatal.h:66
Definition: splash_session.h:24
void fatal_error_abort(char const *reason,...)
An alternative to fatal_error_except() that kills the program and dump core as cleanly as possible.
void fatal_error_except(char const *reason,...)
Throws an exception that will typically kill the Mir server and propagate from mir::run_mir.
void(* fatal_error)(char const *reason,...)
fatal_error() is strictly for "this should never happen" situations that you cannot recover from.

Copyright © 2012-2022 Canonical Ltd.
Generated on Wed Dec 28 21:01:08 UTC 2022
This documentation is licensed under the GPL version 2 or 3.