Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

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.

  • No labels