error()
Sometimes, if you run into a critical error, you may want to explicitly raise an error and stop a component. Using error() terminates the last protected function called and returns the specified error message.
You can also specify what level to raise an error: Level 1 (default) - the error position is where the error function was called. Level 2 - the error position is where the function that called error() was called, etc. This is an elegant way of making errors in required modules more visible.
-- Propagate the error up three levels
error("Bang!", 3)
It’s often used in conjunction with pcall() and iguana.stopOnError().
Â