G.xpcall

From GMod Wiki

Revision as of 19:07, 11 November 2009 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax xpcall( Function func, Function callback )
Where is this used?
Description:
Runs the function and calls callback with an argument of the error message if one occurs.
Returns: nil
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.xpcall]G.xpcall [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCatch an error
Used onNewerShared.png
Code
xpcall( function( ) print( 5/ "e" ) end, print )
Output
[string "*untitled.lua"]:1: attempt to perform arithmetic on a string value
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox