Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptExceptions.cpp
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | if (!stackVal.isNull()) | ||||
ScriptFunction::Call(rq, stackVal, "toString", stackText); | ScriptFunction::Call(rq, stackVal, "toString", stackText); | ||||
std::istringstream stream(stackText); | std::istringstream stream(stackText); | ||||
for (std::string line; std::getline(stream, line);) | for (std::string line; std::getline(stream, line);) | ||||
msg << "\n " << line; | msg << "\n " << line; | ||||
} | } | ||||
LOGERROR("%s", msg.str().c_str()); | LOGERROR("%s", msg.str().c_str()); | ||||
// When running under Valgrind, print more information in the error message | |||||
// VALGRIND_PRINTF_BACKTRACE("->"); | |||||
return true; | return true; | ||||
} | } | ||||
void ScriptException::Raise(const ScriptRequest& rq, const char* format, ...) | void ScriptException::Raise(const ScriptRequest& rq, const char* format, ...) | ||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
va_start(ap, format); | va_start(ap, format); | ||||
// SM is single-threaded, so a static thread_local buffer needs no locking. | // SM is single-threaded, so a static thread_local buffer needs no locking. | ||||
thread_local static char buffer[256]; | thread_local static char buffer[256]; | ||||
vsprintf_s(buffer, ARRAY_SIZE(buffer), format, ap); | vsprintf_s(buffer, ARRAY_SIZE(buffer), format, ap); | ||||
va_end(ap); | va_end(ap); | ||||
// Rather annoyingly, there are no va_list versions of this function, hence the preformatting above. | // Rather annoyingly, there are no va_list versions of this function, hence the preformatting above. | ||||
JS_ReportErrorUTF8(rq.cx, "%s", buffer); | JS_ReportErrorUTF8(rq.cx, "%s", buffer); | ||||
} | } |
Wildfire Games · Phabricator