First, at least it doesn't flat out crash (for that, anyway) but gives you a
lövely baby-blue screen of death that details tons of info about what went wrong, most of the time.
Second, on the offchance that i might seem a bit unhelpful (and rude), let me provide you a small insight that might come as some kind of a relevation:
You do not ship a game that has errors like that.
Now, this is more for the developer of said löve project, if you only wanted to play someone else's game and it errored, then naturally, it's not your fault.
That said, as a developer, usually you want to see issues like that reported as errors so you can fix them; hiding them away doesn't fix anything. Why wouldn't you make sure that the game works on supported systems without relatively small issues like missing files / wrong filepaths?
The fact you cannot resume the state is due to most things not allowing you to resume state in this fashion (unless it's coded in, which takes tons of effort) Even something trivial (in the sense that the game
could function without it) like music or sound effects needing tons of scaffolding code if you want to leave functions all over the place as you want to, should not be suprising. Last i seen a continue button in an application was in Windows 3.1 and even that didn't always work, and it was more magic than you'd probably want it to be.
But let me also offer some other solutions:
1. Easy but Hackish
Code: Select all
local empty_sound = love.sound.newSoundData(1,44100,16,1)
function myLoadMusicFunction(path)
if love.filesystem.isFile(path) then
return love.audio.newSource(path)
else
return love.audio.newSource(empty_sound)
end
end
This will guarantee that you'll have a source, whether or not the file was found, no other method done on the returned Source object will error (probably), but you can take silence to mean that something went wrong.
2. "The usual"
What Ivan already posted above.
3. Hard
Implement hot-reloading.
This one is very complex, unique to what you are coding, and to what you want to accomplish, and probably unneeded, and will waste your time implementing this rather than your project proper. Then again, there is a chance that one would benefit from such system, since this would mean you wouldn't need to always reload everything.
Downsides would be diminished processing speed, at least. (wrapping most things into an xpcall does have its penalties, even if it's only done on one level / with one function)
And yes, i have made an implementation of this before, and i'm not even sure if it worked 100% correctly myself.
If your biggest issue, and the point of this post, was that you needed to restart your game any time you made an error, then by all means go with solution #3, though it might take you more time (and will cause more errors) than you'd care for.
Edit: Also, just to mention it, others before had issues with the BBSOD that löve provides as well, though their issue was that it wasn't user-friendly enough, so they customized the error-handler to be animated, have a button that when clicked, opened (or tried to open) the mail application with a message loaded in regarding the error, or sent an email itself using SMTP or whatever else; just wanted to show that there are many ways to approach one thing.