error

Raises an error message

Prototype

error (message, level)

Description

Raises an error with the supplied message. Never returns. If a level is supplied the error points to the current function (level 1 or nil), the parent function (level 2) and so on.

error ("Insufficient funds") --> error raised: "Insufficient funds"
If you are writing a "validation function" that checks things passed to it, you would normally make the level 2, so that the error message points to the line that calls the validator, rather than the validator itself.

Lua functions

Topics