Skip to content

Instantly share code, notes, and snippets.

@RealEthanPlayzDev
Last active September 13, 2022 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RealEthanPlayzDev/af4f14c56ac2548597ee6cfb2db855a9 to your computer and use it in GitHub Desktop.
Save RealEthanPlayzDev/af4f14c56ac2548597ee6cfb2db855a9 to your computer and use it in GitHub Desktop.
fpcall - full pcall (available in lua and luau)
local function fpcall(f, success, err, ...)
local Results = {pcall(f, ...)}
local Success = table.remove(Results, 1)
if Success then
success(table.unpack(Results))
else
err(table.unpack(Results))
end
return
end
local function fpcall(f: (...any) -> (...any), success: (...any) -> (), err: (errmessage: string) -> (), ... : any)
local Results = {pcall(f, ...)}
local Success = table.remove(Results, 1)
if Success then
success(table.unpack(Results))
else
err(table.unpack(Results))
end
return
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment