当前位置: 首页>>代码示例>>C++>>正文


C++ Local::GetSourceLine方法代码示例

本文整理汇总了C++中Local::GetSourceLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::GetSourceLine方法的具体用法?C++ Local::GetSourceLine怎么用?C++ Local::GetSourceLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Local的用法示例。


在下文中一共展示了Local::GetSourceLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exception_str

std::string V8Engine::compileScript(std::string script)
{
    HandleScope handleScope;
    TryCatch tc;

    Local<String> source = String::New(script.c_str());

    // Compile the source code.

    Local<Script> code = Script::Compile(source);
    if (!code.IsEmpty())
        return "";

    // There were errors, return them

    std::string ret = "";

    Handle<Object> exception = tc.Exception()->ToObject();
    String::AsciiValue exception_str(exception);

    ret += *exception_str; ret += "\n";

    Local<Message> message = tc.Message();

    ret += *(v8::String::Utf8Value( message->Get() )); ret += "\n";
    ret += "Source line: "; ret += *(v8::String::Utf8Value( message->GetSourceLine() )); ret += "\n";
    ret += "Source line number: "; ret += Utility::toString(message->GetLineNumber()); ret += "\n";

    return ret;
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:30,代码来源:script_engine_v8.cpp

示例2: scope

static void logV8Exception(Local<Message> msg, Local<Value> data)
{
	HandleScope scope(V8Runtime::v8_isolate);

	// Log reason and location of the error.
	LOGD(TAG, *v8::String::Utf8Value(msg->Get()));
	LOGD(TAG, "%s @ %d >>> %s",
		*v8::String::Utf8Value(msg->GetScriptResourceName()),
		msg->GetLineNumber(),
		*v8::String::Utf8Value(msg->GetSourceLine()));
}
开发者ID:chmiiller,项目名称:titanium_mobile,代码行数:11,代码来源:V8Runtime.cpp

示例3: handleException

void handleException(TryCatch& tc)
{
    Logging::log(Logging::ERROR, "V8 exception:\r\n");

    HandleScope handleScope;

    Handle<Object> exception = tc.Exception()->ToObject();
    String::AsciiValue exception_str(exception);

    Logging::log(Logging::ERROR, "            : %s\r\n", *exception_str);

/*
    Handle<Array> names = exception->GetPropertyNames();
    for (unsigned int i = 0; i < names->Length(); i++)
    {
        std::string strI = Utility::toString((int)i);
        Logging::log(Logging::ERROR, "    %d : %s : %s\r\n", i,
            *(v8::String::Utf8Value(names->Get(String::New(strI.c_str()))->ToString())),
            *(v8::String::Utf8Value(exception->Get(names->Get(String::New(strI.c_str()))->ToString())->ToString()))
        );
    }
*/

    Local<Message> message = tc.Message();

    Logging::log(Logging::ERROR, "Message: Get: %s\r\n", *(v8::String::Utf8Value( message->Get() )));
    Logging::log(Logging::ERROR, "Message: GetSourceLine: %s\r\n", *(v8::String::Utf8Value( message->GetSourceLine() )));
    Logging::log(Logging::ERROR, "Message: GetScriptResourceName: %s\r\n", *(v8::String::Utf8Value( message->GetScriptResourceName()->ToString() )));
    Logging::log(Logging::ERROR, "Message: GetLineNumber: %d\r\n", message->GetLineNumber() );

    Local<Value> stackTrace = tc.StackTrace();
    if (!stackTrace.IsEmpty())
    {
        Logging::log(Logging::ERROR, "Stack trace: %s\r\n", *(v8::String::Utf8Value( stackTrace->ToString() )));
        printf("\r\n\r\n^Stack trace^: %s\r\n", *(v8::String::Utf8Value( stackTrace->ToString() )));
    }
    else
        Logging::log(Logging::ERROR, "No stack trace available in C++ handler (see above for possible in-script stack trace)\r\n");

    #ifdef SERVER
        std::string clientMessage = *(v8::String::Utf8Value( message->Get() ));
        clientMessage += "  -  ";
        clientMessage += *(v8::String::Utf8Value( message->GetSourceLine() ));
        ServerSystem::fatalMessageToClients(clientMessage);
    #endif

//    assert(0);
    throw ScriptException("Bad!");
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:49,代码来源:script_engine_v8.cpp

示例4: handle_scope

/**
 * 吉里吉里に対して例外通知
 */
void
JSEXCEPTION(Isolate* isolate, TryCatch *try_catch)
{
	HandleScope handle_scope(isolate);

	//HandleScope handle_scope;
	String::Value exception(try_catch->Exception());

	Local<Message> message = try_catch->Message();
	if (!message.IsEmpty()) {
		// 例外表示
		String::Value filename(message->GetScriptResourceName());
		ttstr msg;
		msg += *filename;
		msg += ":";
		msg += tTJSVariant(message->GetLineNumber());
		msg += ":";
		msg += *exception;

		TVPAddLog(msg);
		
		// Print (filename):(line number): (message).
		String::Value sourceline(message->GetSourceLine());
		TVPAddLog(ttstr(*sourceline));

		// エラー行表示
		ttstr wavy;
		int start = message->GetStartColumn();
		for (int i = 0; i < start; i++) {
			wavy += " ";
		}
		int end = message->GetEndColumn();
		for (int i = start; i < end; i++) {
			wavy +="^";
		}
		TVPAddLog(wavy);

		// スタックトレース表示
		String::Value stack_trace(try_catch->StackTrace());
		if (stack_trace.length() > 0) {
			TVPAddLog(ttstr(*stack_trace));
		}
	}
	TVPThrowExceptionMessage(*exception);
}
开发者ID:xmoeproject,项目名称:X-moe,代码行数:48,代码来源:tjsinstance.cpp


注:本文中的Local::GetSourceLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。