Skip to main content

pcall

Function pcall 

Source
pub fn pcall(f: function, args: Repeatable<any>) -> (boolean, Repeatable<any>)
Expand description

Calls the function f with the given arguments in protected mode: errors inside f are not propagated. Returns a status code (a boolean) followed, on success, by all results of the call, or, on failure, by the error object.

local ok, err = pcall(function() error("boom") end)
print(ok, err)  --> false   input:1: boom