diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/scripting/JSModule.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/scripting/JSModule.kt index 7cd02d8a..161da228 100644 --- a/common/src/main/kotlin/me/rhunk/snapenhance/common/scripting/JSModule.kt +++ b/common/src/main/kotlin/me/rhunk/snapenhance/common/scripting/JSModule.kt @@ -135,7 +135,11 @@ class JSModule( obj.get(key, obj) as? ScriptableObject ?: return@contextScope }.get(split.last(), moduleObject) as? Function ?: return@contextScope - function.call(this, moduleObject, moduleObject, args) + runCatching { + function.call(this, moduleObject, moduleObject, args) + }.onFailure { + scriptRuntime.logger.error("Error while calling function $name", it) + } } } } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/SnapEnhance.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/SnapEnhance.kt index b845db20..b1b10718 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/SnapEnhance.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/SnapEnhance.kt @@ -142,6 +142,7 @@ class SnapEnhance { bridgeClient.registerMessagingBridge(messagingBridge) features.init() scriptRuntime.connect(bridgeClient.getScriptingInterface()) + scriptRuntime.eachModule { callFunction("module.onBeforeApplicationLoad", androidContext) } syncRemote() } }