Skip to content

Commit da5f621

Browse files
logic improvement
1 parent e5a82e6 commit da5f621

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/setSpiderMonkeyException.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,20 @@ void setSpiderMonkeyException(JSContext *cx) {
8383
}
8484

8585
// check if it is a Python Exception and already has a stack trace
86-
bool printStack;
86+
bool printStack = true;
8787

88-
JS::Rooted<JS::Value> exn(cx);
88+
JS::RootedValue exn(cx);
8989
JS_GetPendingException(cx, &exn);
9090
if (exn.isObject()) {
9191
JS::RootedObject exnObj(cx, &exn.toObject());
9292
JS::RootedValue tmp(cx);
93-
if (!JS_GetProperty(cx, exnObj, "message", &tmp)) {
94-
printStack = true;
95-
}
96-
else if (tmp.isString()) {
93+
if (JS_GetProperty(cx, exnObj, "message", &tmp) && tmp.isString()) {
9794
JS::RootedString rootedStr(cx, tmp.toString());
9895
printStack = strstr(JS_EncodeStringToUTF8(cx, rootedStr).get(), "JS Stack Trace") == NULL;
9996
}
100-
else {
101-
printStack = true;
102-
}
103-
}
104-
else {
105-
printStack = true;
10697
}
10798

99+
108100
JS_ClearPendingException(cx);
109101

110102
// `PyErr_SetString` uses `PyErr_SetObject` with `PyUnicode_FromString` under the hood

0 commit comments

Comments
 (0)