Mir
Loading...
Searching...
No Matches
fatal.h
Go to the documentation of this file.
1/*
2 * Copyright © 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
23#ifndef MIR_FATAL_H_
24#define MIR_FATAL_H_
25
26namespace mir
27{
37extern void (*fatal_error)(char const* reason, ...);
38
44void fatal_error_except(char const* reason, ...);
45
51[[noreturn]]
52void fatal_error_abort(char const* reason, ...);
53
54// Utility class to override & restore existing error handler
56{
57public:
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
69private:
70 void (*old_fatal_error_handler)(char const* reason, ...);
72 FatalErrorStrategy& operator=(FatalErrorStrategy const&) = delete;
73};
74} // namespace mir
75
76#endif // MIR_FATAL_H_
Definition fatal.h:56
FatalErrorStrategy(void(*fatal_error_handler)(char const *reason,...))
Definition fatal.h:58
~FatalErrorStrategy()
Definition fatal.h:64
Definition splash_session.h:22
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-2024 Canonical Ltd.
Generated on Sat Aug 17 07:04:01 UTC 2024
This documentation is licensed under the GPL version 2 or 3.