本文整理汇总了C++中Handle::GetEndColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::GetEndColumn方法的具体用法?C++ Handle::GetEndColumn怎么用?C++ Handle::GetEndColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::GetEndColumn方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void V8Util::openJSErrorDialog(TryCatch &tryCatch)
{
JNIEnv *env = JNIUtil::getJNIEnv();
if (!env) {
return;
}
Handle<Message> message = tryCatch.Message();
jstring title = env->NewStringUTF("Runtime Error");
jstring errorMessage = TypeConverter::jsValueToJavaString(message->Get());
jstring resourceName = TypeConverter::jsValueToJavaString(message->GetScriptResourceName());
jstring sourceLine = TypeConverter::jsValueToJavaString(message->GetSourceLine());
env->CallStaticVoidMethod(
JNIUtil::krollRuntimeClass,
JNIUtil::krollRuntimeDispatchExceptionMethod,
title,
errorMessage,
resourceName,
message->GetLineNumber(),
sourceLine,
message->GetEndColumn());
env->DeleteLocalRef(title);
env->DeleteLocalRef(errorMessage);
env->DeleteLocalRef(resourceName);
env->DeleteLocalRef(sourceLine);
}
示例2: exception
std::ostream& operator<<( std::ostream &s, const v8::TryCatch * try_catch ){
HandleScope handle_scope;
v8::String::Utf8Value exception(try_catch->Exception());
Handle<v8::Message> message = try_catch->Message();
if (message.IsEmpty()) {
s << *exception << endl;
}
else {
v8::String::Utf8Value filename(message->GetScriptResourceName());
int linenum = message->GetLineNumber();
cout << *filename << ":" << linenum << " " << *exception << endl;
v8::String::Utf8Value sourceline(message->GetSourceLine());
cout << *sourceline << endl;
int start = message->GetStartColumn();
for (int i = 0; i < start; i++)
cout << " ";
int end = message->GetEndColumn();
for (int i = start; i < end; i++)
cout << "^";
cout << endl;
}
//if ( try_catch->next_ ) // disabled for v8 bleeding edge
// s << try_catch->next_;
return s;
}
示例3: ReportException
void ReportException(TryCatch* tryCatch)
{
// HandleScope handleScope;
String::Utf8Value exception(tryCatch->Exception());
const char* exceptionString = ToCString(exception);
Handle<Message> message = tryCatch->Message();
if (message.IsEmpty()) {
// V8 didn't provide any extra information about this error; just
// print the exception.
throw std::runtime_error("Unknown error "+ std::string(exceptionString));
} else {
// Print (filename):(line number): (message).
String::Utf8Value filename(message->GetScriptResourceName());
const char* filenameString = ToCString(filename);
int linenum = message->GetLineNumber();
std::stringstream ss;
// Print filename and linenum if applicable
if(!message->GetScriptResourceName()->IsUndefined()) {
ss << filenameString <<":"<< linenum <<" ";
}
ss << exceptionString << std::endl;
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceline_string = ToCString(sourceline);
ss << sourceline_string << std::endl;
// Print wavy underline (GetUnderline is deprecated).
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
ss << " ";
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
ss << "^";
}
ss << std::endl;
String::Utf8Value stack_trace(tryCatch->StackTrace());
if (stack_trace.length() > 0) {
const char* stack_trace_string = ToCString(stack_trace);
ss << stack_trace_string;
}
throw std::runtime_error(ss.str());
}
}
示例4: DisplayExceptionLine
void DisplayExceptionLine (TryCatch &try_catch, std::string& err_msg) {
// Prevent re-entry into this function.
static bool displayed_error = false;
if (displayed_error) return;
displayed_error = true;
HandleScope scope;
Handle<Message> message = try_catch.Message();
fprintf(stderr, "\n");
err_msg = "JavaScript Exception\n\n";
if (!message.IsEmpty()) {
// Print (filename):(line number): (message).
String::Utf8Value filename(message->GetScriptResourceName());
const char* filename_string = *filename;
int linenum = message->GetLineNumber();
fprintf(stderr, "%s:%i\n", filename_string, linenum);
err_msg += filename_string;
err_msg += ":";
char num_conv[10];
sprintf(num_conv, "%i", linenum);
err_msg += num_conv;
err_msg += "\n";
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceline_string = *sourceline;
int start = message->GetStartColumn();
int end = message->GetEndColumn();
// fprintf(stderr, "---\nsourceline:%s\noffset:%d\nstart:%d\nend:%d\n---\n", sourceline_string, start, end);
fprintf(stderr, "%s\n", sourceline_string);
err_msg += sourceline_string;
err_msg += "\n";
// Print wavy underline (GetUnderline is deprecated).
for (int i = 0; i < start; i++) {
fputc((sourceline_string[i] == '\t') ? '\t' : ' ', stderr);
}
for (int i = start; i < end; i++) {
fputc('^', stderr);
}
fputc('\n', stderr);
err_msg += "\n";
}
}
示例5: ReportException
////////////////////////////////////////////////////////////////////////////////
// lifted from node.js file node.cc
void ReportException(TryCatch *try_catch)
{
HandleScope scope;
Handle<Message> message = try_catch->Message();
std::string filename_string = "";
std::string sourceline_string = "";
int linenum = 0;
int start = 0;
int end = 0;
if (!message.IsEmpty()) {
String::Utf8Value filename(message->GetScriptResourceName());
filename_string = *filename;
linenum = message->GetLineNumber();
String::Utf8Value sourceline(message->GetSourceLine());
sourceline_string = *sourceline;
start = message->GetStartColumn();
end = message->GetEndColumn();
}
String::Utf8Value trace(try_catch->StackTrace());
std::string tracestr;
if(trace.length() != 0)
{
tracestr = *trace;
}
std::ostringstream os;
os << std::endl << sourceline_string << std::endl;
for (int i = 0; i < start; i++)
{
os << " ";
}
for (int i = start; i < end; i++)
{
os << "^";
}
os << tracestr << "\n";
std::string msg = os.str();
dtEntity::LogManager::GetInstance().LogMessage(dtEntity::LogLevel::LVL_ERROR, filename_string, "", linenum, msg);
}
示例6: stringifyException
std::string stringifyException(const v8::TryCatch& try_catch, bool suppressBacktrace) {
HandleScope scope;
std::string output = "";
Handle<Message> message = try_catch.Message();
if (suppressBacktrace || message.IsEmpty()) {
std::string exception_string = V8::stringToStdString(try_catch.Exception().As<String>());
// V8 didn't provide any extra information about this error; just
// print the exception.
output += exception_string;
output += "\n";
} else {
// filename:line
output += V8::stringToStdString(
message->GetScriptResourceName().As<String>()
) + ":" + boost::lexical_cast<std::string>(
message->GetLineNumber()
) + "\n";
// Print line of source code.
output += V8::stringToStdString(message->GetSourceLine()) + "\n";
// Print wavy underline (GetUnderline is deprecated).
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
output += " ";
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
output += "^";
}
output += "\n";
// Print out the stack trace.
std::string stackTrace = V8::stringToStdString(try_catch.StackTrace().As<String>());
if (stackTrace.length() > 0) {
output += stackTrace + "\n";
}
}
return output;
}
示例7: GetExceptionInfo
const string JSMain::GetExceptionInfo(Isolate* isolate, TryCatch* try_catch)
{
HandleScope handle_scope(isolate);
String::Utf8Value exception(try_catch->Exception());
const char *exception_string = js_safe_str(*exception);
Handle<Message> message = try_catch->Message();
string res;
if (message.IsEmpty()) {
// V8 didn't provide any extra information about this error; just return the exception.
res = exception_string;
} else {
String::Utf8Value filename(message->GetScriptResourceName());
const char *filename_string = js_safe_str(*filename);
int linenum = message->GetLineNumber();
ostringstream ss;
ss << filename_string << ":" << linenum << ": " << exception_string << "\r\n";
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char *sourceline_string = js_safe_str(*sourceline);
ss << sourceline_string << "\r\n";
// Print wavy underline.
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
ss << " ";
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
ss << "^";
}
res = ss.str();
}
return res;
}
示例8: ReportException
void SMJS_Plugin::ReportException(TryCatch* try_catch){
HandleScope handle_scope(isolate);
fprintf(stderr, "----------------------------- JAVASCRIPT EXCEPTION -----------------------------");
String::Utf8Value exception(try_catch->Exception());
const char* exception_string = ToCString(exception);
Handle<Message> message = try_catch->Message();
if (message.IsEmpty()) {
// V8 didn't provide any extra information about this error; just
// print the exception.
fprintf(stderr, "%s\n", exception_string);
} else {
// Print (filename):(line number): (message).
String::Utf8Value filename(message->GetScriptResourceName());
const char* filename_string = ToCString(filename);
int linenum = message->GetLineNumber();
fprintf(stderr, "%s:%d: %s\n", filename_string, linenum, exception_string);
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceline_string = ToCString(sourceline);
fprintf(stderr, "%s\n", sourceline_string);
// Print wavy underline (GetUnderline is deprecated).
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
fprintf(stderr, " ");
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
fprintf(stderr, "^");
}
fprintf(stderr, "\n");
String::Utf8Value stack_trace(try_catch->StackTrace());
if (stack_trace.length() > 0) {
const char* stack_trace_string = ToCString(stack_trace);
fprintf(stderr, "%s\n", stack_trace_string);
}
}
fprintf(stderr, "--------------------------------------------------------------------------------");
}
示例9: toSTLString
std::string toSTLString( const v8::TryCatch * try_catch ) {
stringstream ss;
//while ( try_catch ){ // disabled for v8 bleeding edge
v8::String::Utf8Value exception(try_catch->Exception());
Handle<v8::Message> message = try_catch->Message();
if (message.IsEmpty()) {
ss << *exception << endl;
}
else {
v8::String::Utf8Value filename(message->GetScriptResourceName());
if (*filename) {
int linenum = message->GetLineNumber();
ss << *filename << ":" << linenum << " ";
}
ss << *exception << endl;
v8::String::Utf8Value sourceline(message->GetSourceLine());
ss << *sourceline << endl;
int start = message->GetStartColumn();
for (int i = 0; i < start; i++)
ss << " ";
int end = message->GetEndColumn();
for (int i = start; i < end; i++)
ss << "^";
ss << endl;
}
//try_catch = try_catch->next_;
//}
return ss.str();
}
示例10: ReportError
int ReportError(TryCatch& try_catch){
cs::String str;
HandleScope handle_scope;
v8::String::Value exception(try_catch.Exception());
const wchar_t* exception_string = ToCString(exception);
Handle<v8::Message> message = try_catch.Message();
if (message.IsEmpty()) {
str.Format(L"%s\n",exception_string);
} else {
cs::String buf;
v8::String::Value filename(message->GetScriptResourceName());
const wchar_t* filename_string = ToCString(filename);
int linenum = message->GetLineNumber();
buf.Format(L"file:\t%s\r\nline:\t%i\r\n%s\r\n\r\n", filename_string, linenum, exception_string);
str += buf;
v8::String::Value sourceline(message->GetSourceLine());
const wchar_t* sourceline_string = ToCString(sourceline);
buf.Format(L"%s", sourceline_string);
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
//str += L" ";
}
buf.Insert('^',start);
buf.Trim();
str += buf;
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
//str += L"^";
}
/*str += L"\n";
v8::String::Value stack_trace(try_catch.StackTrace());
if (stack_trace.length() > 0) {
const wchar_t* stack_trace_string = ToCString(stack_trace);
buf.Format(L"%s\n", stack_trace_string);
str += buf;
}*/
}
return MessageBox(0,str,L"Error",MB_ICONERROR);
}
示例11: prettyPrintException
// Taken from Google's Shell example.
void PrettyPrinter::prettyPrintException(v8::TryCatch *try_catch, std::string *ex_string) {
ex_string->clear();
HandleScope handle_scope;
String::Utf8Value exception(try_catch->Exception());
const char* exception_string = toCString(exception);
Handle<Message> message = try_catch->Message();
if (message.IsEmpty()) {
ex_string->append(exception_string);
ex_string->append("\n");
} else {
String::Utf8Value filename(message->GetScriptResourceName());
const char* filename_string = toCString(filename);
int linenum = message->GetLineNumber();
ex_string->append(filename_string);
ex_string->append(":");
ex_string->append(intToString(linenum));
ex_string->append(": ");
ex_string->append(exception_string);
ex_string->append("\n");
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceline_string = toCString(sourceline);
ex_string->append(sourceline_string);
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
ex_string->append(" ");
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
ex_string->append("^");
}
ex_string->append("\n");
String::Utf8Value stack_trace(try_catch->StackTrace());
if (stack_trace.length() > 0) {
const char* stack_trace_string = toCString(stack_trace);
ex_string->append(stack_trace_string);
ex_string->append("\n");
}
}
}
示例12: reportException
// Slight modification to an original function found in the V8 sample shell.cc.
void Global::reportException(TryCatch* tryCatch) {
HandleScope handleScope(fIsolate);
String::Utf8Value exception(tryCatch->Exception());
const char* exceptionString = to_cstring(exception);
Handle<Message> message = tryCatch->Message();
if (message.IsEmpty()) {
// V8 didn't provide any extra information about this error; just
// print the exception.
fprintf(stderr, "%s\n", exceptionString);
} else {
// Print (filename):(line number): (message).
String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
const char* filenameString = to_cstring(filename);
int linenum = message->GetLineNumber();
fprintf(stderr,
"%s:%i: %s\n", filenameString, linenum, exceptionString);
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceLineString = to_cstring(sourceline);
fprintf(stderr, "%s\n", sourceLineString);
// Print wavy underline.
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
fprintf(stderr, " ");
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
fprintf(stderr, "^");
}
fprintf(stderr, "\n");
String::Utf8Value stackTrace(tryCatch->StackTrace());
if (stackTrace.length() > 0) {
const char* stackTraceString = to_cstring(stackTrace);
fprintf(stderr, "%s\n", stackTraceString);
}
}
}
示例13: reportException
static void reportException(v8::TryCatch &try_catch, bool show_line)
{
using namespace v8;
Handle<Message> message = try_catch.Message();
v8::String::Utf8Value error(try_catch.Exception());
if (error.length() > 0)
{
std::ostringstream errorMsg;
/*
02:50:22.863: [CID=00000000] JS: File undefined:12
[CID=00000000] JS: Source Line var notheetoo = nothere.subst(0, 10);
[CID=00000000] JS:
^
[CID=00000000] JS:
{TypeError: Cannot call method 'subst' of undefined
at RouteProfile.isTellMeRoutable (unknown source)
at RouteProfile.isRoutable (unknown source)
at handle_request (unknown source)
}
*/
if (show_line && !message.IsEmpty())
{
// Print (filename):(line number): (message).
String::Utf8Value filename(message->GetScriptResourceName());
const char* filename_string = toCString(filename);
int linenum = message->GetLineNumber();
//fprintf(stderr, "%s:%i\n", filename_string, linenum);
errorMsg << filename_string << ":" << linenum << std::endl;
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceline_string = toCString(sourceline);
// HACK HACK HACK
//
// FIXME
//
// Because of how CommonJS modules work, all scripts are wrapped with a
// "function (function (exports, __filename, ...) {"
// to provide script local variables.
//
// When reporting errors on the first line of a script, this wrapper
// function is leaked to the user. This HACK is to remove it. The length
// of the wrapper is 62. That wrapper is defined in src/node.js
//
// If that wrapper is ever changed, then this number also has to be
// updated. Or - someone could clean this up so that the two peices
// don't need to be changed.
//
// Even better would be to get support into V8 for wrappers that
// shouldn't be reported to users.
int offset = linenum == 1 ? 62 : 0;
//fprintf(stderr, "%s\n", sourceline_string + offset);
errorMsg << sourceline_string + offset << std::endl;
// Print wavy underline (GetUnderline is deprecated).
int start = message->GetStartColumn();
for (int i = offset; i < start; i++)
{
errorMsg << " ";
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++)
{
errorMsg << "^";
}
errorMsg << std::endl;
}
String::Utf8Value trace(try_catch.StackTrace());
if (trace.length() > 0)
{
errorMsg << *trace;
}
OSS_LOG_ERROR("\t[CID=00000000] JS: " << *error << std::endl << "{" << std::endl << errorMsg.str() << std::endl << "}");
}
}