Exceptions: Difference between revisions
→{{header|langur}}
Flexibeast (talk | contribs) (Add page to "Flow control" category.) |
Langurmonkey (talk | contribs) |
||
Line 1,597:
A catch causes all the statements preceding it within a block to be the implicit try block.
throw "not a math exception"
▲<syntaxhighlight lang="langur">throw "not a math exception"
▲catch[.e] {
▲ if .e'cat == "math" {
# change result...
} else {
Line 1,618 ⟶ 1,617:
An exception variable may be specified, or you can simply use the implicit variable, which is _err.
<syntaxhighlight lang="langur">
100 / 0
catch {
Line 1,631:
</syntaxhighlight>
<syntaxhighlight lang="langur">
val .safediv = fn(
safediv(7, 0) # 0
</syntaxhighlight>
|