Exceptions: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 120: | Line 120: | ||
//This code is always executed after exiting the try block |
//This code is always executed after exiting the try block |
||
} |
} |
||
==[[Perl]]== |
|||
[[Category:Perl]] |
|||
# throw an exception |
|||
die "Danger, danger, Will Robinson!"; |
|||
# catch an exception and show it |
|||
eval { |
|||
die "this could go wrong mightily"; |
|||
}; |
|||
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. |
|||
==[[Python]]== |
==[[Python]]== |