Pass small trivially-copyable types by value
[openal-soft.git] / common / alassert.cpp
blobf50642308d7bad7510bcb828ab3b741cd368ad4d
2 #include "alassert.h"
4 #include <exception>
5 #include <stdexcept>
6 #include <string>
8 namespace al {
10 [[noreturn]]
11 void do_assert(const char *message, int linenum, const char *filename, const char *funcname) noexcept
13 std::string errstr{filename};
14 errstr += ':';
15 errstr += std::to_string(linenum);
16 errstr += ": ";
17 errstr += funcname;
18 errstr += ": ";
19 errstr += message;
20 /* Calling std::terminate in a catch block hopefully causes the system to
21 * provide info about the caught exception in the error dialog. At least on
22 * Linux, this results in the process printing
24 * terminate called after throwing an instance of 'std::runtime_error'
25 * what(): <message here>
27 * before terminating from a SIGABRT. Hopefully Windows and Mac will do the
28 * appropriate things with the message for an abnormal termination.
30 try {
31 throw std::runtime_error{errstr};
33 catch(...) {
34 std::terminate();
38 } /* namespace al */