-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexceptionhandler.hpp
41 lines (34 loc) · 1.29 KB
/
exceptionhandler.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//@ {
//@ "targets":[{"name":"exceptionhandler.hpp","type":"include"}]
//@ ,"dependencies_extra":[{"ref":"exceptionhandler.o","rel":"implementation"}]
//@ }
#ifndef MAIKE_EXCEPTIONHANDLER_HPP
#define MAIKE_EXCEPTIONHANDLER_HPP
#include "visibility.hpp"
namespace Maike
{
class ErrorMessage;
PRIVATE [[noreturn]] void exceptionHandlerDefault(const ErrorMessage& message);
#ifndef __GNUC__
/**Function called when an exception happens.
*
* An ExceptionHandler is a function that is called when an exception happens
* There are three legal ways to leave an ExceptionHandler:
*
* 1. Throw the ErrorMessage. This is the default action.
* 2. Package the ErrorMessage into another object, and throw the result.
* 3. Terminate the process through any appropriate function provided by
* the runtime library or the operating system.
*
* An ExceptionHandler should not throw anything else than the ErrorMessage,
* or a repackaged version of it.
*/
typedef void (*ExceptionHandler)(const ErrorMessage& message);
#else
typedef __attribute__((__noreturn__)) decltype(&exceptionHandlerDefault) ExceptionHandler;
#endif
PRIVATE void exceptionHandlerSet(ExceptionHandler eh);
PRIVATE [[noreturn]] void exceptionRaise(const ErrorMessage& message);
PRIVATE ExceptionHandler exceptionHandlerGet();
}
#endif