My current code and what I found:
local unhandledErrorListener = function( errorEvent ) print("unhandled error listener") composer:removeHidden() local currScene = composer.getSceneName( "current" ) if (currScene ~= nil) then composer.removeScene( currScene ) end composer.gotoScene("UI.errorScene", { params = { error = errorEvent, loadFunction = gameLoaderFunction --this function perform loading last save } }) return true end
So normally I see this situation:
X scene show phase = will
X scene show phase = did
ERROR: Runtime error
unhandled error listener
error scene created
error scene show phase = will
error scene show phase = did
remove current (X scene)
But if error occured during another scene show event composer stuck to remove current scene:
X scene show phase = will
X scene show phase = did
ERROR: Runtime error <- this occured right in scene:show event
unhandled error listener
error scene created
error scene show phase = will
remove current (X scene)
So error scene show event never occured with phase = did. And on screen I still see X scene (on which error occured)
The only solution so far for me is to wrap all logic for “did show” phase into timer.performWithDelay