unhandledError

Type Event
Revision Release 2024.3703
Keywords unhandledError, runtime

Overview

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.

Properties

Examples

Error Message
local unhandledErrorListener = function( event )
    print( "We have a problem: " .. event.errorMessage )
end

Runtime:addEventListener( "unhandledError", unhandledErrorListener )
Stack Trace
function errorHandler( event )
    print( event.errorMessage, event.stackTrace )
end 

Runtime:addEventListener( "unhandledError", errorHandler )