G.error
From GMod Wiki
Revision as of 20:45, 11 November 2009 by Crazy Quebecer (Talk | contribs)
| Function | |
| Syntax |
error( String message, Number level ) Where is this used? |
| Description: | |
| Throws a new error with the text message as well as a stack trace. Level is used to determine where the error is reported to. Execution of the file is stopped. | |
| Returns: | nil |
| Part of Library: | Global Functions |
| Realm: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=G.error]G.error [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
| Description | Error level 1 |
|---|---|
| Used on | |
| Code | function fail(level) error("failed",level) end --fail(0) fail(1) fail(2) |
| Output | fail.lua:2: failed |
| Description | Error level 2 |
|---|---|
| Used on | |
| Code | function fail(level) error("failed",level) end --fail(0) --fail(1) fail(2) |
| Output | fail.lua:6: failed |
Notes
- The level argument just delegates where the error is sent to.
- Level 0 does not report positioning ( no line numbers )
- Level 1 shows the line number of the error (default behavior)
- Level 2 shows the line number of the function call that caused the error. See the example above.