try/catch/finally lowers to pcall scaffolding. At most one catch clause is supported.
try
{
DoWork();
}
catch (Exception e)
{
HandleError(e.Message);
}
finally
{
Cleanup();
}local ok__, err__ = pcall(function()
DoWork()
end)
if not ok__ then
local e = err__
HandleError(e)
end
Cleanup()throw inside a try block emits error(...). throw outside a try block is a transpiler error.
throw new Exception("bad");error("bad")Multiple catch clauses, catch with type filters, when clauses, and re-throw (throw;) produce a transpiler error.