Library for Foundry VTT which provides module developers with a simple way to modify core Foundry VTT code, while reducing the likelihood of conflict with other modules.
GNU Lesser General Public License v3.0
35
stars
15
forks
source link
[BUG] Incorrect error message when calling the libWrapper API before the libWrapper.Ready hook #72
Describe the bug
When trying to register a wrapper before the libWrapper.Ready hook, if this happens before game.modules is available, libWrapper will try to construct an error message and fail with an error message like:
[Detected 2 packages: lib-wrapper, XYZ]
at PackageInfo.get exists [as exists] (libWrapper-package_info.js:328)
at de (libWrapper-api.js:273)
at Function.šregister [as register] (libWrapper-api.js:471)
at XYZ.js:5
To Reproduce
Steps to reproduce the behavior:
Write a module which calls libWrapper.register before the libWrapper.Ready hook fires.
Enter a world and enable the module.
Refresh.
See the error in the JS console.
Expected behavior
libWrapper should give the error Not allowed to register wrappers before the 'libWrapper.Ready' hook fires instead.
Technical Details (please complete the following information):
LibWrapper Version: 1.12.8.0 (and older)
FoundryVTT Version: Any
Browser & Version: Any
Additional context
This seems to be caused by api.js:475, which throws a LibWrapperPackageError exception when libWrapper isn't ready yet, which will trigger a PackageInfo::exists call during the error message construction.
This PackageInfo::exists method does not correctly handle the case where game.modules is undefined.
Describe the bug When trying to register a wrapper before the
libWrapper.Ready
hook, if this happens beforegame.modules
is available, libWrapper will try to construct an error message and fail with an error message like:To Reproduce Steps to reproduce the behavior:
libWrapper.register
before thelibWrapper.Ready
hook fires.Expected behavior libWrapper should give the error
Not allowed to register wrappers before the 'libWrapper.Ready' hook fires
instead.Technical Details (please complete the following information):
Additional context This seems to be caused by
api.js:475
, which throws aLibWrapperPackageError
exception when libWrapper isn't ready yet, which will trigger aPackageInfo::exists
call during the error message construction.This
PackageInfo::exists
method does not correctly handle the case wheregame.modules
is undefined.