Total-RP / Total-RP-3

The best roleplaying add-on for World of Warcraft.
http://curse.totalrp.com
Apache License 2.0
33 stars 19 forks source link

Prefer securecall for non-fatal error dispatch #898

Closed Meorawr closed 1 month ago

Meorawr commented 1 month ago

The securecall function implicitly routes all errors that occur in the invoked function to the global error handler. Previously this was preferable to xpcall as it would enable the error handler to display a locals dump, but as of recently this difference was removed.

However, currently in 11.0 there's a bug where xpcall with CallErrorHandler doesn't actually work sometimes. The default script errors window itself encounters an error when this combination of functions is used, resulting in the error being silently dropped on the floor with no indication whatsoever that something has gone wrong.

The securecall method however isn't impacted by this bug, and we've been making changes elsewhere to use securecall for this type of stuff anyway, so might as well just commit to the idea and blanket replace all usages of xpcall with securecall instead.

One thorny area is the module management interface. For that I've elected to remove its weird dual-handling of initialization errors (which differs between debug and release builds) and instead just allow errors to route to the default error handler.