Difference between revisions of "Error"

From GiderosMobile
(removed language stuff)
 
(2 intermediate revisions by one other user not shown)
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Terminates the last protected function called and returns message as the error message. Function error never returns.
 
Terminates the last protected function called and returns message as the error message. Function error never returns.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
error(message,level)
 
error(message,level)
</source>
+
</syntaxhighlight>
  
 
  Usually, error adds some information about the error position at the beginning of the ''message''. The ''level'' argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.
 
  Usually, error adds some information about the error position at the beginning of the ''message''. The ''level'' argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.
Line 14: Line 14:
 
'''message''': (string) error message<br/>
 
'''message''': (string) error message<br/>
 
'''level''': (number) the call stack level '''optional'''<br/>
 
'''level''': (number) the call stack level '''optional'''<br/>
 +
 +
=== See also ===
 +
'''https://luau.org/library#global-functions'''<br/>
  
 
{{(global)}}
 
{{(global)}}

Latest revision as of 12:16, 21 July 2025

Available since: Gideros 2011.6
Class: (global)

Description

Terminates the last protected function called and returns message as the error message. Function error never returns.

error(message,level)
Usually, error adds some information about the error position at the beginning of the message. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.

Parameters

message: (string) error message
level: (number) the call stack level optional

See also

https://luau.org/library#global-functions