2019-05-04 18:03:25 -07:00
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2020-12-21 18:00:43 -08:00
|
|
|
#include "except.h"
|
2019-05-04 18:03:25 -07:00
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdarg>
|
|
|
|
|
|
|
|
|
|
#include "opthelpers.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace al {
|
|
|
|
|
|
2023-01-13 02:09:54 -08:00
|
|
|
base_exception::~base_exception() = default;
|
|
|
|
|
|
2024-01-24 19:56:33 -08:00
|
|
|
void base_exception::setMessage(const char *msg, std::va_list args)
|
2019-05-04 18:03:25 -07:00
|
|
|
{
|
2024-01-24 19:56:33 -08:00
|
|
|
/* NOLINTBEGIN(*-array-to-pointer-decay) */
|
2020-04-10 15:11:40 -07:00
|
|
|
std::va_list args2;
|
2019-05-04 18:03:25 -07:00
|
|
|
va_copy(args2, args);
|
|
|
|
|
int msglen{std::vsnprintf(nullptr, 0, msg, args)};
|
2023-03-01 11:35:39 -08:00
|
|
|
if(msglen > 0) LIKELY
|
2019-05-04 18:03:25 -07:00
|
|
|
{
|
|
|
|
|
mMessage.resize(static_cast<size_t>(msglen)+1);
|
2024-01-03 19:10:15 -08:00
|
|
|
std::vsnprintf(mMessage.data(), mMessage.length(), msg, args2);
|
2019-05-04 18:03:25 -07:00
|
|
|
mMessage.pop_back();
|
|
|
|
|
}
|
|
|
|
|
va_end(args2);
|
2024-01-24 19:56:33 -08:00
|
|
|
/* NOLINTEND(*-array-to-pointer-decay) */
|
2019-05-04 18:03:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace al
|