error

From ComputerCraft
Jump to: navigation, search

error
Function
Syntax
error()
Returns nil
API Base globals
Source CC:Tweaked

Throws an error with the specified message at the current line and call frame or if specified, level frames upward.

ExampleExampleThrowing an error
Throws an error with specified error message.
Code
error("example error message")
Output
program.lua:1: example error message
ExampleExampleThrowing an error at a different level
Throws an error with specified error message at a higher frame.
(note how it specified the error as happening on line 5, where myFunction() is being called, because we traversed up.)
Code
local function myFunction()
  error("example error message", 2)
end

myFunction()
Output
program.lua:5: example error message