Issue #390 new

More robust boot, audio, and graphics scripts

created an issue

The Lua scripts embedded into the executable rely on global variables for many vital functions and tables. LÖVE can terminate with misleading error messages, no error messages at all, or get stuck in a loop if one of those variables get changed.

One example would be the print function used in the error handler. If it gets replaced by the user and causes an error, the whole error handler blows up.

Another thing is the insufficient handling of invalid UTF-8 in the error handler. Error messages (encoded with ISO 8859-1 or similar) with bytes above 127 will likely throw an error at resulting in a "Invalid UTF-8" error screen with a stack trace to the error handler.

Using local references for the Lua functions can prevent some of these failures. Getting clean references to the LÖVE functions is a bit trickier because the initialization of the modules can happen (almost) anywhere and anytime.

The lookup for the custom error handling function should happen at error time. It's currently not possible to catch things like syntax errors with custom error handlers.

Comments (4)

  1. kevinclancy

    Errors should not occur in these scripts. Right now, if I call love.event.push('q'), an error propogates into boot.lua. Since the user does not typically have access to this script, the generated error would confuse most users. In this particular example, the unrecognized event should raise an error as soon as push is called.

  2. Log in to comment