Causes a Lua error if a condition is failed


See also Lua library functions.

Signature:

value = assert(condition, "message")

Arguments:

  • condition - Any value (commonly the result of an expression) (value)
  • message - Error message to be produced if condition is false or nil (string)

Returns:

  • value - The condition value provided, if not false or nil (value)

Examples:

assert(x < y)
-- causes a Lua error if the value of x is not less than the value of y when called

assert(not UnitIsDead("player"), "Oh noes!"))
-- causes a Lua error with text "Oh noes!" if the player is dead when called
This function is defined in the Lua standard libraries