2024-06-30 19:35:57 +00:00
|
|
|
|
|
|
|
|
#include "alassert.h"
|
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
[[noreturn]]
|
|
|
|
|
void throw_error(const std::string &message)
|
|
|
|
|
{
|
|
|
|
|
throw std::runtime_error{message};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* namespace */
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
namespace al {
|
|
|
|
|
|
|
|
|
|
[[noreturn]]
|
|
|
|
|
void do_assert(const char *message, int linenum, const char *filename, const char *funcname) noexcept
|
|
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
/* Throwing an exception that tries to leave a noexcept function will
|
|
|
|
|
* hopefully cause the system to provide info about the caught exception in
|
|
|
|
|
* an error dialog. At least on Linux, this results in the process printing
|
2024-06-30 19:35:57 +00:00
|
|
|
*
|
|
|
|
|
* terminate called after throwing an instance of 'std::runtime_error'
|
|
|
|
|
* what(): <message here>
|
|
|
|
|
*
|
|
|
|
|
* before terminating from a SIGABRT. Hopefully Windows and Mac will do the
|
2025-09-03 16:09:27 +00:00
|
|
|
* appropriate things with the message to alert the user about an abnormal
|
|
|
|
|
* termination.
|
2024-06-30 19:35:57 +00:00
|
|
|
*/
|
2025-09-03 16:09:27 +00:00
|
|
|
auto errstr = std::string{filename};
|
|
|
|
|
errstr += ':';
|
|
|
|
|
errstr += std::to_string(linenum);
|
|
|
|
|
errstr += ": ";
|
|
|
|
|
errstr += funcname;
|
|
|
|
|
errstr += ": ";
|
|
|
|
|
errstr += message;
|
|
|
|
|
|
|
|
|
|
throw_error(errstr);
|
2024-06-30 19:35:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* namespace al */
|