diff options
author | Sven Gothel <[email protected]> | 2023-05-03 16:17:49 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-03 16:17:49 +0200 |
commit | ec167fd05661a5b02dd406c87081f84a0f8dd77d (patch) | |
tree | 9c4669e471c9969bda59265381b18d2d416db060 /core/except.cpp | |
parent | 0d14d30808cfe7b9e3413353e3eef8a0f201399a (diff) | |
parent | d3875f333fb6abe2f39d82caca329414871ae53b (diff) |
Merge branch 'v1.23.1'
Resolved Conflicts:
CMakeLists.txt
Diffstat (limited to 'core/except.cpp')
-rw-r--r-- | core/except.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/except.cpp b/core/except.cpp new file mode 100644 index 00000000..45fd4eb5 --- /dev/null +++ b/core/except.cpp @@ -0,0 +1,30 @@ + +#include "config.h" + +#include "except.h" + +#include <cstdio> +#include <cstdarg> + +#include "opthelpers.h" + + +namespace al { + +base_exception::~base_exception() = default; + +void base_exception::setMessage(const char* msg, std::va_list args) +{ + std::va_list args2; + va_copy(args2, args); + int msglen{std::vsnprintf(nullptr, 0, msg, args)}; + if(msglen > 0) LIKELY + { + mMessage.resize(static_cast<size_t>(msglen)+1); + std::vsnprintf(const_cast<char*>(mMessage.data()), mMessage.length(), msg, args2); + mMessage.pop_back(); + } + va_end(args2); +} + +} // namespace al |