Skip to content

Commit 0dc70af

Browse files
logic improvement
1 parent e8c439a commit 0dc70af

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/setSpiderMonkeyException.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ void setSpiderMonkeyException(JSContext *cx) {
8686
bool printStack = true;
8787

8888
JS::RootedValue exn(cx);
89-
JS_GetPendingException(cx, &exn);
90-
if (exn.isObject()) {
91-
JS::RootedObject exnObj(cx, &exn.toObject());
92-
JS::RootedValue tmp(cx);
93-
if (JS_GetProperty(cx, exnObj, "message", &tmp) && tmp.isString()) {
94-
JS::RootedString rootedStr(cx, tmp.toString());
95-
printStack = strstr(JS_EncodeStringToUTF8(cx, rootedStr).get(), "JS Stack Trace") == NULL;
89+
if (JS_GetPendingException(cx, &exn)) {
90+
if (exn.isObject()) {
91+
JS::RootedObject exnObj(cx, &exn.toObject());
92+
JS::RootedValue tmp(cx);
93+
if (JS_GetProperty(cx, exnObj, "message", &tmp) && tmp.isString()) {
94+
JS::RootedString rootedStr(cx, tmp.toString());
95+
printStack = strstr(JS_EncodeStringToUTF8(cx, rootedStr).get(), "JS Stack Trace") == NULL;
96+
}
9697
}
9798
}
9899

0 commit comments

Comments
 (0)