debug/traceback

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Arguments missing from description.)
(All arguments are optional)
 
Line 10: Line 10:
 
|name=thread
 
|name=thread
 
|desc=Thread (ie. error object from xpcall error handler) to build traceback for.
 
|desc=Thread (ie. error object from xpcall error handler) to build traceback for.
 +
|default=current thread
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 15: Line 16:
 
|name=message
 
|name=message
 
|desc=Appended at the beginning of the traceback.
 
|desc=Appended at the beginning of the traceback.
 +
|default=nil
 
}}
 
}}
 
{{Arg
 
{{Arg

Latest revision as of 19:43, 26 September 2016

 debug.traceback( )

Contents

Description

Returns a full execution stack trace.

Arguments

thread thread=current thread

Thread (ie. error object from xpcall error handler) to build traceback for.

Arguments

string message=nil

Appended at the beginning of the traceback.

Arguments

number level=1

Which level to start the traceback.

Returns

string

A dump of the execution stack.

Examples

Example

Prints the traceback into console.

print(debug.traceback())

Output:

> print(debug.traceback())...

stack traceback:

lua_run:1: in main chunk

Examples

Example

Defines two functions that are later visible in the traceback. Enter "lua_run TracebackTest()" into the development console to achieve exact results.

function TracebackTest()
     AnotherTracebackFunction()
end

function AnotherTracebackFunction()
     print(debug.traceback())
end

Output:

stack traceback:
       lua_run:1: in function 'AnotherTracebackFunction'
       lua_run:1: in function 'TracebackTest'
lua_run:1: in main chunk
Personal tools
Navigation