Type Function Library (globals) Revision Release 2022.3683 Keywords assert, error See also error()
Issues an error and aborts the program when the value of its first argument is false
nil
or false
)
This function is useful for catching (and avoiding) unexpected situations and bugs.
assert( v [, message] )
Any. Issues an error when this value is false.
String. An error message. When absent, it defaults to "assertion failed!". The error message is displayed in the Corona Simulator Console.
-- Abort the program if the image is not found (in the Resource directory) local img = display.newImage( "imageWithWrongName.png" ) assert( img, "Error: Image not found!" )