mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
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:
8
init.lua
8
init.lua
@@ -51,9 +51,17 @@ local function loadModule(self, module)
|
||||
if chunk then
|
||||
local fn, err = load(chunk, ('@@ox_lib/imports/%s/%s.lua'):format(module, context))
|
||||
|
||||
if not fn or err then
|
||||
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()
|
||||
self[module] = result or noop
|
||||
|
||||
Reference in New Issue
Block a user