Jump to content

Exceptions: Difference between revisions

→‎{{header|Perl}}: Reverted 56483 (yes, those are exceptions). Added lang tags.
(→‎{{header|Perl}}: Reverted 56483 (yes, those are exceptions). Added lang tags.)
Line 764:
=={{header|Perl}}==
 
<lang perl># throw an exception
Perl 5 does not actually support exceptions at all, but they can be simulated with:
die "Danger, danger, Will Robinson!";
 
# throwcatch an exception and show it
eval {
die "Danger, danger, Will Robinson!";
die "this could go wrong mightily";
};
# catch an exception and show it
print $@ if $@;
eval {
 
die "this could go wrong mightily";
# rethrow
};
die $@;</lang>
print $@ if $@;
# rethrow
die $@;
See http://perldoc.perl.org/perlvar.html#%24EVAL_ERROR for the meaning of the special variable <tt>$@</tt>. See http://search.cpan.org/dist/Error for an advanced, object based -exception handling.
 
=={{header|PHP}}==
845

edits

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