Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/jni/ExceptionUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,7 @@ void ExceptionUtil::OnUncaughtError(Handle<Message> message, Handle<Value> error
errorObject = Exception::Error(ConvertToV8String(errorMessage));
}

auto thiz = Object::New(isolate);
auto func = handler.As<Function>();

// Notify the developer for the exception and let him do some additional job here
// TODO: Launching UI at this point may be erroneous, think how to prevent it
func->Call(thiz, 1, &errorObject);

// check whether the developer marked the error as "Caught"
// As per discussion, it is safer to ALWAYS kill the application due to uncaught error(s)
Expand All @@ -189,6 +184,14 @@ void ExceptionUtil::OnUncaughtError(Handle<Message> message, Handle<Value> error
//NativeScriptRuntime::APP_FAIL(errorMessage.c_str());
}

void ExceptionUtil::CallJFuncWithErr(Isolate* isolate, Handle<Value> handler, Handle<Value> errObj)
{
auto thiz = Object::New(isolate);
auto func = handler.As<Function>();

func->Call(thiz, 1, &errObj);
}

string ExceptionUtil::GetErrorMessage(const Handle<Message>& message, const Handle<Value>& error){
stringstream ss;

Expand All @@ -200,7 +203,7 @@ string ExceptionUtil::GetErrorMessage(const Handle<Message>& message, const Hand
String::Utf8Value utfError(str);
ss << *utfError << endl;
ss << "File: \"" << ConvertToString(message->GetScriptResourceName().As<String>());
ss << ", line: " << message->GetLineNumber() << ", column: " << message->GetStartColumn() << endl;
ss << ", line: " << message->GetLineNumber() - Constants::MODULE_LINES_OFFSET << ", column: " << message->GetStartColumn() << endl;

string stackTraceMessage = GetErrorStackTrace(message->GetStackTrace());
ss << "StackTrace: " << endl << stackTraceMessage;
Expand Down Expand Up @@ -267,7 +270,7 @@ bool ExceptionUtil::CheckForException(Isolate *isolate, const string& methodName
String::Utf8Value file(tc.Message()->GetScriptResourceName());
int line = tc.Message()->GetLineNumber();
int column = tc.Message()->GetStartColumn();
DEBUG_WRITE("Error: %s @line: %d, column: %d", *error, line, column);
DEBUG_WRITE("Error: %s @line: %d, column: %d", *error, line - Constants::MODULE_LINES_OFFSET, column);

auto pv = new Persistent<Value>(isolate, ex);

Expand Down