Page 1 of 1

Custom error handler

Posted: Tue Jul 28, 2015 7:48 pm
by FlattenedTesseract
Is there any way to make a game not stop when there is an error?
What I want to do is to change the game's state inside love.errhand(), kinda like this:

Code: Select all

function love.errhand(msg)
    setState("error", {msg}) --the {msg} part sends msg to the new state
end
The error state contains an update and a draw function that are called from love.update and love.draw and should restart the game on a keypress, so the solution i'm looking for should not stop love.run.

Re: Custom error handler

Posted: Tue Jul 28, 2015 7:51 pm
by Jasoco
You can try and play around with Löve's current Error Handler:

[wiki]love.errhand[/wiki]

Also look into assert() and pcall() which will let you execute code and catch errors without stopping the execution.

Re: Custom error handler

Posted: Tue Jul 28, 2015 8:21 pm
by FlattenedTesseract
Oh, you just made me realise that I can catch and handle the errors myself, I don't have to make love do it :awesome:
Thanks!