Skip to content

Commit ab61c00

Browse files
committed
fix(android): clean exception message
1 parent 4af47d9 commit ab61c00

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: android/runtime/v8/src/native/V8Util.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)
144144
HandleScope scope(isolate);
145145

146146
Local<Context> context = isolate->GetCurrentContext();
147-
Local<Message> message = tryCatch.Message();
148147
Local<Value> exception = tryCatch.Exception();
149148

149+
// Re-create message from exception to obtain a clean stack.
150+
// tryCatch.Message() can include internal methods where an exception was re-thrown.
151+
Local<Message> message = Exception::CreateMessage(isolate, exception);
152+
150153
Local<Value> jsStack;
151154
Local<Value> javaStack;
152155

@@ -158,9 +161,6 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)
158161
}
159162

160163
// Javascript stack trace not provided? Attempt to obtain current stack trace.
161-
if (jsStack.IsEmpty() || jsStack->IsNullOrUndefined()) {
162-
jsStack = tryCatch.StackTrace();
163-
}
164164
if (jsStack.IsEmpty() || jsStack->IsNullOrUndefined()) {
165165
Local<StackTrace> frames = message->GetStackTrace();
166166
if (frames.IsEmpty() || !frames->GetFrameCount()) {
@@ -173,6 +173,9 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)
173173
}
174174
}
175175
}
176+
if (jsStack.IsEmpty() || jsStack->IsNullOrUndefined()) {
177+
jsStack = tryCatch.StackTrace();
178+
}
176179

177180
jstring title = env->NewStringUTF("Runtime Error");
178181
jstring errorMessage = TypeConverter::jsValueToJavaString(isolate, env, message->Get());

0 commit comments

Comments
 (0)