try catch
Description
This is a utility class to add try - catch functionallity
Installation
Copy one of these commands into your ComputerCraft terminal:
wget:
wget https://raw.githubusercontent.com/Poeschl/computercraft-scripts/main/try-catch.lua try_catchArchive:
wget https://cc.shobie.xyz/cc/get/gh-Poeschl-computercraft-scripts-try-catch try_catch
Quick Install:
wget https://cc.shobie.xyz/cc/get/gh-Poeschl-computercraft-scripts-try-catch try catch
Usage
Run: try-catch
Tags
Source
View Original SourceCode Preview
-- This is a utility class to add try - catch functionallity
-- include it by downloading to your computer and import it with `require "try-catch"`
function catch(what)
return what[1]
end
function try(what)
local status, result = pcall(what[1])
if not status then
what[2](result)
end
return result
end