Exceptions: Difference between revisions
m
→{{header|Sidef}}: updated code
m (→{{header|Wren}}: Changed to Wren S/H) |
m (→{{header|Sidef}}: updated code) |
||
Line 3,094:
An exception is thrown by the ''die'' keyword, which, if not caught, it terminates the program with an appropriate exit code.
<syntaxhighlight lang="ruby">try {
die "I'm dead!"
}
▲catch { |type, msg|
▲ say "msg: #{msg}"; # msg: I'm dead! at test.sf line 2.
▲};
say "I'm alive..."
die "Now I'm dead!"
say "Or am I?"
{{out}}
<pre>
Line 3,109 ⟶ 3,108:
msg: I'm dead! at test.sf line 2.
I'm alive...
Now I'm dead! at test.sf line
</pre>
|