Causes a Lua error if a condition is failed

See also Lua library functions.


value = assert(condition, "message")


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


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


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