1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include "stdafx.h"
#include "Assert.h"
AssertionException::AssertionException(const String &file, nat line, const String &expr, const String &msg)
: file(file), line(line), expr(expr), msg(msg) {
// If no one catches it, print it now as well.
PLN(what());
PLN(format(stackTrace));
}
AssertionException::AssertionException(const String &file, nat line, const String &expr, const char *msg)
: file(file), line(line), expr(expr), msg(String(msg)) {
// If no one catches it, print it now as well.
PLN(what());
PLN(format(stackTrace));
}
String AssertionException::what() const {
std::wostringstream s;
s << L"Assertion failed: ";
if (!msg.empty())
s << msg << L" (" << expr << L")";
else
s << expr;
s << endl;
s << file << L"(L" << line << L")";
return s.str();
}
void debugAssertFailed(const wchar_t *msg) {
PLN(msg);
debugAssertFailed();
}
void debugAssertFailed(const String &msg) {
PLN(msg);
debugAssertFailed();
}
#ifdef VISUAL_STUDIO
void debugAssertFailed() {
DebugBreak();
std::terminate();
}
#else
void debugAssertFailed() {
std::terminate();
}
#endif
|