From ffd2219200cb804a1338c99b0f8440016bf73ccd Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 14 Jun 2020 10:34:49 +0000 Subject: [PATCH] Don't overwrite JS error reporting by calling JS_ReportError. Upstream spidermonkey supports JSNative error reporting by returning an explicit failure code. This provides a full stacktrace. Calling JS_ReportError, removed upstream, removes that stacktrace. Instead, we should simply LOGERROR. Based on a patch by: elexis Reviewed By: wraitii Differential Revision: https://code.wildfiregames.com/D2627 This was SVN commit r23773. --- source/gui/ObjectBases/IGUIObject.cpp | 2 +- source/gui/Scripting/JSInterface_IGUIObject.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/gui/ObjectBases/IGUIObject.cpp b/source/gui/ObjectBases/IGUIObject.cpp index 48241210ed..b7f582555d 100644 --- a/source/gui/ObjectBases/IGUIObject.cpp +++ b/source/gui/ObjectBases/IGUIObject.cpp @@ -431,7 +431,7 @@ bool IGUIObject::ScriptEventWithReturn(const CStr& eventName, const JS::HandleVa if (!JS_CallFunctionValue(cx, obj, handlerVal, paramData, &result)) { - JS_ReportError(cx, "Errors executing script event \"%s\"", eventName.c_str()); + LOGERROR("Errors executing script event \"%s\"", eventName.c_str()); return false; } return JS::ToBoolean(result); diff --git a/source/gui/Scripting/JSInterface_IGUIObject.cpp b/source/gui/Scripting/JSInterface_IGUIObject.cpp index 1ee82d216b..c7335bac1d 100644 --- a/source/gui/Scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/Scripting/JSInterface_IGUIObject.cpp @@ -122,7 +122,7 @@ bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::Handle return true; } - JS_ReportError(cx, "Property '%s' does not exist!", propName.c_str()); + LOGERROR("Property '%s' does not exist!", propName.c_str()); return false; } @@ -159,7 +159,7 @@ bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::Handle { if (vp.isPrimitive() || vp.isNull() || !JS_ObjectIsFunction(cx, &vp.toObject())) { - JS_ReportError(cx, "on- event-handlers must be functions"); + LOGERROR("on- event-handlers must be functions"); return result.fail(JSMSG_NOT_FUNCTION); } @@ -172,7 +172,7 @@ bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::Handle if (e->SettingExists(propName)) return e->m_Settings[propName]->FromJSVal(cx, vp, true) ? result.succeed() : result.fail(JSMSG_TYPE_ERR_BAD_ARGS); - JS_ReportError(cx, "Property '%s' does not exist!", propName.c_str()); + LOGERROR("Property '%s' does not exist!", propName.c_str()); return result.fail(JSMSG_UNDEFINED_PROP); } @@ -199,7 +199,7 @@ bool JSI_IGUIObject::deleteProperty(JSContext* cx, JS::HandleObject obj, JS::Han return result.succeed(); } - JS_ReportError(cx, "Only event handlers can be deleted from GUI objects!"); + LOGERROR("Only event handlers can be deleted from GUI objects!"); return result.fail(JSMSG_UNDEFINED_PROP); }