Type Event Revision Release 2022.3683 Keywords unhandledError, runtime
These events occur when an application experiences a runtime error. They are only dispatched to the global Runtime object, meaning that errors in callbacks and listeners are not caught.
If true
is returned from the listener for "unhandledError"
, the error is suppressed and application execution will continue. Returning false
(or nothing) from the listener will allow the runtime error to be reported to the user and the application to terminate.
local unhandledErrorListener = function( event ) print( "We have a problem: " .. event.errorMessage ) end Runtime:addEventListener( "unhandledError", unhandledErrorListener )
function errorHandler( event ) print( event.errorMessage, event.stackTrace ) end Runtime:addEventListener( "unhandledError", errorHandler )