error

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

ExampleThrowing an error
Throws an error with specified error message.
Code
error("example error message")
Output
program.lua:1: example error message
ExampleThrowing 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

error
Function
Syntax
error(
  • message : string
  • level? : number
)

Returns nil
API Base globals
Source CC:Tweaked
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.