diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-22 16:12:31 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-22 16:12:31 +0100 |
commit | 7e12ebdf945d40d6f11872cf5852c9bb54d1864f (patch) | |
tree | d81f4661e2fd47f487cf0c9627baa1e21dc45b37 /src/crepe/facade | |
parent | 61148c757a1f742ff09e40e5347e74e638c7371c (diff) |
big WIP
Diffstat (limited to 'src/crepe/facade')
-rw-r--r-- | src/crepe/facade/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/crepe/facade/SignalCatch.cpp | 25 | ||||
-rw-r--r-- | src/crepe/facade/SignalCatch.h | 24 |
3 files changed, 51 insertions, 0 deletions
diff --git a/src/crepe/facade/CMakeLists.txt b/src/crepe/facade/CMakeLists.txt index 243ae46..4873e8d 100644 --- a/src/crepe/facade/CMakeLists.txt +++ b/src/crepe/facade/CMakeLists.txt @@ -6,6 +6,7 @@ target_sources(crepe PUBLIC DB.cpp FontFacade.cpp Font.cpp + SignalCatch.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -16,5 +17,6 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES DB.h FontFacade.h Font.h + SignalCatch.h ) diff --git a/src/crepe/facade/SignalCatch.cpp b/src/crepe/facade/SignalCatch.cpp new file mode 100644 index 0000000..ad92d28 --- /dev/null +++ b/src/crepe/facade/SignalCatch.cpp @@ -0,0 +1,25 @@ +#include <stdexcept> + +#include "SignalCatch.h" + +using namespace crepe; +using namespace std; + +SignalCatch::SignalCatch() { + segvcatch::init_segv(&SignalCatch::segv); + segvcatch::init_fpe(&SignalCatch::fpe); +} + +SignalCatch::~SignalCatch() { + segvcatch::init_segv(); + segvcatch::init_fpe(); +} + +void SignalCatch::segv() { + throw runtime_error("segmentation fault"); +} + +void SignalCatch::fpe() { + throw domain_error("floating point exception"); +} + diff --git a/src/crepe/facade/SignalCatch.h b/src/crepe/facade/SignalCatch.h new file mode 100644 index 0000000..4562215 --- /dev/null +++ b/src/crepe/facade/SignalCatch.h @@ -0,0 +1,24 @@ +#pragma once + +#include <segvcatch.h> + +namespace crepe { + +class SignalCatch { +public: + SignalCatch(); + ~SignalCatch(); + +private: + static void segv(); + static void fpe(); + +public: + SignalCatch(const SignalCatch &) = delete; + SignalCatch(SignalCatch &&) = delete; + SignalCatch & operator=(const SignalCatch &) = delete; + SignalCatch & operator=(SignalCatch &&) = delete; +}; + +} + |