summaryrefslogtreecommitdiff
path: root/source/fud_assert.cpp
diff options
context:
space:
mode:
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());
+}
+
+}