Improve call stack for Hooks
Closed this issue · 1 comments
ruipin commented
Due to Foundry swallowing exceptions that occur inside hooks, libWrapper hooks Hooks._call
to catch any unhandled exceptions.
However, this leads to very ugly call stacks any time a hook is triggered, which leads some people to mistakenly believe that an issue is caused by libWrapper, when libWrapper was not involved.
Ideally, we should improve this so that the hooks callstack isn't polluted by libWrapper. Multiple possibilities exist, e.g.:
- Do not decorate the
Hooks._call
wrapper. - Override the
Hooks._call
wrapper, instead of wrapping it, reducing the number of libWrapper entries in the callstack, and avoid rethrowing. - Move this hook to a different file not called
errors.js
, e.g.hooks-listener.js
.