Control flow
try / catch / throw
Things explode. I would rather they explode into a catch than onto your console with no warning.
v2.0 finally lets you catch them on purpose.
try / catch
try the dangerous bit.
Close it with end;.
Then catch the error, named, like a guest who arrived uninvited.
try;
showln call SendRequest("GET", url, body);
end;
catch(error);
throw newobj Error(error);
end;
finally
finally runs after the try, whether or not anyone threw a tantrum. Cleanup. Last words. Closing the door.
try;
showln x;
end;
catch(error);
showln error;
end;
finally;
showln "done";
end;
throw
throw sends an error up the stack.
Using stdlib/error.alana is recommended, so the thing you throw is an
Error object instead of a loose feeling.
including "stdlib/error.alana"; throw newobj Error(error);