@@ -144,9 +144,12 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)
144
144
HandleScope scope (isolate);
145
145
146
146
Local<Context> context = isolate->GetCurrentContext ();
147
- Local<Message> message = tryCatch.Message ();
148
147
Local<Value> exception = tryCatch.Exception ();
149
148
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
+
150
153
Local<Value> jsStack;
151
154
Local<Value> javaStack;
152
155
@@ -158,9 +161,6 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)
158
161
}
159
162
160
163
// Javascript stack trace not provided? Attempt to obtain current stack trace.
161
- if (jsStack.IsEmpty () || jsStack->IsNullOrUndefined ()) {
162
- jsStack = tryCatch.StackTrace ();
163
- }
164
164
if (jsStack.IsEmpty () || jsStack->IsNullOrUndefined ()) {
165
165
Local<StackTrace> frames = message->GetStackTrace ();
166
166
if (frames.IsEmpty () || !frames->GetFrameCount ()) {
@@ -173,6 +173,9 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)
173
173
}
174
174
}
175
175
}
176
+ if (jsStack.IsEmpty () || jsStack->IsNullOrUndefined ()) {
177
+ jsStack = tryCatch.StackTrace ();
178
+ }
176
179
177
180
jstring title = env->NewStringUTF (" Runtime Error" );
178
181
jstring errorMessage = TypeConverter::jsValueToJavaString (isolate, env, message->Get ());
0 commit comments