Log the buffer format when queueing mismatched buffers
[openal-soft.git] / core / except.cpp
blob45fd4eb5f7a05926f77c9b2c41dabfd0af05853c
2 #include "config.h"
4 #include "except.h"
6 #include <cstdio>
7 #include <cstdarg>
9 #include "opthelpers.h"
12 namespace al {
14 base_exception::~base_exception() = default;
16 void base_exception::setMessage(const char* msg, std::va_list args)
18 std::va_list args2;
19 va_copy(args2, args);
20 int msglen{std::vsnprintf(nullptr, 0, msg, args)};
21 if(msglen > 0) LIKELY
23 mMessage.resize(static_cast<size_t>(msglen)+1);
24 std::vsnprintf(const_cast<char*>(mMessage.data()), mMessage.length(), msg, args2);
25 mMessage.pop_back();
27 va_end(args2);
30 } // namespace al