Defold errors and warnings

Errors and warnings are spat out when for various reasons when you’ve been a naughty developer. These seem to come in two flavours; ERROR and WARNING. Some examples:

ERROR:GAMESYS
ERROR:SCRIPT
ERROR:GAMEOBJECT

WARNING:RENDER
WARNING:DLIB
WARNING:PARTICLE
WARNING:GRAPHICS
WARNING:GAMEOBJECT
WARNING:SOUND
WARNING:ENGINE
WARNING:RESOURCE

Two questions:

  1. Is there a hard and fast rule as to which of these warnings or errors cause a hard crash (game shuts down) and which ones cause a soft crash (allowing the game to continue, but limping badly, usually towards a cliff edge). My guess is that errors always cause a hard crash and warnings never do.

  2. I use sys.set_error_handler() for crash reporting. Have all errors from this callback already caused a crash, or does it also report soft crashes? If so, is there a way to distinguish between soft and hard crashes?

SOFT CRASHES
sys.set_error_handler() will only catch errors which originate from Lua or extension/engine code which validates arguments or calls functions such as lua_error(), ie soft crashes. These things would get caught:

error("Catch me!")
assert(1 == 2)
print(nil + 5)
msg.post(nil, "foobar")
go.set_position(5)

You will still see the “ERROR:Blablabla” message in the console.

Warnings will not get caught by sys.get_error_handler().

HARD CRASHES
Hard crashes will not log anything like “ERROR:I’m hard crashing” to the console. The game will shut down unexpectedly and without any chance for you as a developer to do anything about it.

The engine will however detect the hard crash and write crash data to file. This data can be read by you on the next startup. See: https://defold.com/ref/stable/crash/

3 Likes