sandboxos => tildefriends

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3157 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2016-03-12 18:50:43 +00:00
commit 7c6a377c0b
94 changed files with 27121 additions and 0 deletions

57
src/TaskTryCatch.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "TaskTryCatch.h"
#include "Task.h"
#include <iostream>
const char* TaskTryCatch::toString(const v8::String::Utf8Value& value) {
return *value ? *value : "(null)";
}
TaskTryCatch::TaskTryCatch(Task* task) {
_tryCatch.SetCaptureMessage(true);
_tryCatch.SetVerbose(true);
}
TaskTryCatch::~TaskTryCatch() {
if (_tryCatch.HasCaught()) {
if (v8::Isolate* isolate = v8::Isolate::GetCurrent()) {
if (Task* task = reinterpret_cast<Task*>(isolate->GetData(0))) {
std::cerr << "Task[" << task << ':' << task->getName() << "] ";
}
}
std::cerr << "Exception:\n";
v8::Handle<v8::Message> message(_tryCatch.Message());
if (!message.IsEmpty()) {
std::cerr
<< toString(v8::String::Utf8Value(message->GetScriptResourceName()))
<< ':'
<< message->GetLineNumber()
<< ": "
<< toString(v8::String::Utf8Value(_tryCatch.Exception()))
<< '\n';
std::cerr << toString(v8::String::Utf8Value(message->GetSourceLine())) << '\n';
for (int i = 0; i < message->GetStartColumn(); ++i) {
std::cerr << ' ';
}
for (int i = message->GetStartColumn(); i < message->GetEndColumn(); ++i) {
std::cerr << '^';
}
if (!message->GetStackTrace().IsEmpty()) {
for (int i = 0; i < message->GetStackTrace()->GetFrameCount(); ++i) {
std::cerr << "oops " << i << "\n";
}
}
std::cerr << '\n';
} else {
std::cerr << toString(v8::String::Utf8Value(_tryCatch.Exception())) << '\n';
}
v8::String::Utf8Value stackTrace(_tryCatch.StackTrace());
if (stackTrace.length() > 0) {
std::cerr << *stackTrace << '\n';
}
}
}