summaryrefslogtreecommitdiff
path: root/source/fud_assert.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-09-23 07:36:16 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-09-23 07:36:16 -0500
commit0b860bb5dd6d2007db605291d239a6a9d41f57d1 (patch)
treefab140e03a3665236503d1405de9d33ba58ccc4a /source/fud_assert.cpp
parent7da829d48f9059c83ab9cada2c850621e8bbd3f3 (diff)
Installable library.
Diffstat (limited to 'source/fud_assert.cpp')
-rw-r--r--source/fud_assert.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/fud_assert.cpp b/source/fud_assert.cpp
new file mode 100644
index 0000000..f3358df
--- /dev/null
+++ b/source/fud_assert.cpp
@@ -0,0 +1,26 @@
+#include "fud_assert.hpp"
+
+#include "fud_array.hpp"
+
+#include <cstdio>
+#include <stdexcept>
+#include <format>
+
+namespace fud {
+
+void assertFail(const char* assertion, const char* file, unsigned int line, const char* function) noexcept(false)
+{
+ constexpr size_t ASSERT_MSG_SIZE = 1024;
+ Array<char, ASSERT_MSG_SIZE> buffer{};
+ static_cast<void>(std::format_to_n(
+ buffer.data(),
+ buffer.size() - 1U,
+ "{}:{}: {}:Assertion `{}` failed",
+ file,
+ line,
+ function,
+ assertion));
+ throw std::runtime_error(buffer.data());
+}
+
+}