Jump to content

Exceptions/Catch an exception thrown in a nested call: Difference between revisions

m
m (→‎{{header|Wren}}: Changed to Wren S/H)
m (→‎{{header|Sidef}}: updated code)
Line 3,095:
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func baz(i) { die "U#{i}" };
func bar(i) { baz(i) };
 
func foo {
[0, 1].each { |i|
try { bar(i) }
catch { |_, msg|
msg ~~ /^U0/  ? say "Function foo() caught exception U0"
 : die msg; # re-raise the exception
};
}
}
 
foo();</syntaxhighlight>
{{out}}
<pre>
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.