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.
This commit is contained in:
Linden
2025-03-18 02:29:31 +11:00
parent f5396edc78
commit 6fcb83101f

View File

@@ -52,7 +52,15 @@ local function loadModule(self, module)
local fn, err = load(chunk, ('@@ox_lib/imports/%s/%s.lua'):format(module, context)) local fn, err = load(chunk, ('@@ox_lib/imports/%s/%s.lua'):format(module, context))
if not fn or err then 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 end
local result = fn() local result = fn()