NarcEngine 0.1.1
C++ Vulkan game engine
 
Loading...
Searching...
No Matches
MethodExceptionHandler.h
1//
2// Created by theoh on 27/02/2025.
3//
4
5#pragma once
6
7#define NARC_EXECUTE_HANDLED(handlerName, method, ...) NARCLOG_HANDLED_METHOD_NAME(handlerName).execute([__VA_ARGS__] { method; })
8
9namespace narclog
10{
11 class FatalException;
12
13 class NARCLOG_API MethodExceptionHandler final
14 {
15 friend class ExceptionHandlerBuilder;
16
17 public:
18 ~MethodExceptionHandler();
19
20 int invoke();
21 int execute(const std::function<void()>& method);
22
23 private:
24 explicit MethodExceptionHandler(const std::function<void()>& function,
25 const std::function<void()>& finallyCallback);
26
27 const std::function<void()> m_function;
28 const std::function<void()> m_finallyCallback;
29
30 bool m_handleAllNonFatalExceptionAsFatal = false;
31 bool m_rethrowFatal = false;
32
33 const char* m_name = nullptr;
34
35 void fatalExceptionHandler(const FatalException& e);
36 void errorExceptionHandler(const std::exception& e) const;
37 GETTER std::string format(const std::exception& e) const;
38 GETTER std::string format(const std::exception& e, const std::string& handlerName) const;
39
40 void finally() const;
41 };
42} // narclog
Definition FatalException.h:10