1
Vote

V8Exception class to get important information such as LineNumber and Stacktrace

description

When exceptions are thrown they lack important information such as the linenumber and stacktrace of the error.
 
I've already implemented this myself (without the stacktrace because it takes a FILE* and I'm not sure how to use that short of making a temporary file)
 
I've got it implemented like this:
    v8::Handle<v8::Value> result = this->compiledScript->GetScript()->Run();
    if (tryCatch.HasCaught()) {
        v8::String::Utf8Value error(tryCatch.Exception());
        v8::Local<v8::Message> msg = tryCatch.Message();
        v8::String::Utf8Value sourceline(msg->GetSourceLine());
        String^ exceptionMessage = gcnew String((const char*)*error);
        String^ sourceLineStr = gcnew String((const char*)*sourceline);

        throw gcnew V8Exception(sourceLineStr,
            exceptionMessage,
            msg->GetLineNumber(),
            msg->GetStartColumn(),
            msg->GetEndColumn(),
            msg->GetStartPosition(),
            msg->GetEndPosition()
            );

    }

comments