Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 708 Bytes

File metadata and controls

47 lines (37 loc) · 708 Bytes

Exceptions

try / catch / finally

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

throw inside a try block emits error(...). throw outside a try block is a transpiler error.

throw new Exception("bad");
error("bad")

Unsupported

Multiple catch clauses, catch with type filters, when clauses, and re-throw (throw;) produce a transpiler error.