NarcEngine
0.1.1
C++ Vulkan game engine
Loading...
Searching...
No Matches
ExceptionHandlerBuilder.h
1
//
2
// Created by theoh on 27/02/2025.
3
//
4
5
#pragma once
6
7
//TODO Modify to use reflection
8
9
#define NARCLOG_HANDLED_METHOD_NAME(handlerName) narclog__method_handler_##handlerName
10
11
#define NARCLOG_PREPARE_HANDLER(name) auto NARCLOG_HANDLED_METHOD_NAME(name) = narclog::ExceptionHandlerBuilder() \
12
.handleAllNonFatalExceptionAsFatal() \
13
->setName(#name) \
14
->rethrowFatal() \
15
->create()
20
#define NARCLOG_EXECUTE_FATAL_SAFE(method) narclog::ExceptionHandlerBuilder() \
21
.bind([] { method; }) \
22
->handleAllNonFatalExceptionAsErrorLog() \
23
->handleFatal() \
24
->create() \
25
.invoke();
26
27
#define NARCLOG_EXECUTE_FINALLY_FATAL_SAFE(method, finallyCallback) narclog::ExceptionHandlerBuilder() \
28
.bind([] { method; }) \
29
->bindFinally([] { finallyCallback; }) \
30
->handleAllNonFatalExceptionAsFatal() \
31
->handleFatal() \
32
->create() \
33
.invoke();
34
35
namespace
narclog
36
{
37
class
MethodExceptionHandler
;
38
39
class
NARCLOG_API
ExceptionHandlerBuilder
final
40
{
41
public
:
42
ExceptionHandlerBuilder
* bind(
const
std::function<
void
()>& function);
43
ExceptionHandlerBuilder
* bindFinally(
const
std::function<
void
()>& finallyCallback);
44
45
ExceptionHandlerBuilder
* handleAllNonFatalExceptionAsFatal();
46
ExceptionHandlerBuilder
* handleAllNonFatalExceptionAsErrorLog();
47
ExceptionHandlerBuilder
* rethrowFatal();
48
ExceptionHandlerBuilder
* handleFatal();
49
50
ExceptionHandlerBuilder
* setName(
const
char
* name);
51
52
GETTER
MethodExceptionHandler
create()
const
;
53
54
private
:
55
std::function<void()> m_function;
56
std::function<void()> m_finallyCallback;
57
58
bool
m_handleAllNonFatalExceptionAsFatal =
false
;
59
bool
m_rethrowFatal =
true
;
60
61
const
char
* m_name =
nullptr
;
62
};
63
}
narclog::ExceptionHandlerBuilder
Definition
ExceptionHandlerBuilder.h:40
narclog::MethodExceptionHandler
Definition
MethodExceptionHandler.h:14
narc_engine
core
narclog
include
exceptions
ExceptionHandlerBuilder.h
Generated on Tue Mar 25 2025 13:27:02 for NarcEngine by
1.13.2