/
error()

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().

 

Related content

Error Handling
Error Handling
More like this
Retry Library
More like this
Make it easy for your sales team to understand context around your customers
Make it easy for your sales team to understand context around your customers
Read with this
pcall()
More like this
Salesforce
Salesforce
Read with this
iguana.stopOnError()
iguana.stopOnError()
More like this