From 6fcb83101f1339a3d6df0ade82af39a1ea2c2e97 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 18 Mar 2025 02:29:31 +1100 Subject: [PATCH] refactor(init): attempt to catch module errors from invalid installs Since people continue to drag and drop updates without clearing old files, then spend days or weeks complaining about script errors. --- init.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 9032055..c96c29d 100644 --- a/init.lua +++ b/init.lua @@ -52,7 +52,15 @@ local function loadModule(self, module) local fn, err = load(chunk, ('@@ox_lib/imports/%s/%s.lua'):format(module, context)) if not fn or err then - return error(('\n^1Error importing module (%s): %s^0'):format(dir, err), 3) + if shared then + lib.print.warn(("An error occurred when importing '@ox_lib/imports/%s'.\nThis is likely caused by improperly updating ox_lib.\n%s'") + :format(module, err)) + fn, err = load(shared, ('@@ox_lib/imports/%s/shared.lua'):format(module)) + end + + if not fn or err then + return error(('\n^1Error importing module (%s): %s^0'):format(dir, err), 3) + end end local result = fn()