do
throw 3.14159 # Can throw any value.
catch error
// Only one catch block. If you want to dispatch based on the type of the exception, implement it yourself.
throw // Throw without a value will re-throw the current exception
ensure
// Always runs
end
The catch and ensure can be attached to any do block, even the blocks that represent control structures and functions:
define returns_pi do
throw 3.14159
catch error
i = error
ensure
return i
end
In terms of implementation, the Signal class should be augmented to have an error field that will get propagated up until it is caught.
General syntax:
The catch and ensure can be attached to any do block, even the blocks that represent control structures and functions:
In terms of implementation, the
Signal
class should be augmented to have anerror
field that will get propagated up until it is caught.