G.xpcall

From GMod Wiki

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