Try catch and finally
Aquarius has an error mechanism: Error
. When you create an Error
, it will bubble from current scope to the outmost scope.
try expression
If there is an error created in try
block, it will jump to catch
block, and you can refer error
to fetch error details.
if you catch the error, it will stop bubbling outwoards.
(try
{expression}..
catch
{expression}..
)
In addition, you can add a finally
block in try
.
(try
{expression}..
catch
{expression}..
finally
{expression}..
)
It ensures that its expressions are always executed.
example
(try
(puts:1)
(puts:2)
(Error:"222")
catch
(puts:3)
(Error:"333")
finally
(puts:4)
)
output
1
2
3
4
Error: 333