Exceptions: Difference between revisions

no edit summary
(Added Control Structures template)
No edit summary
Line 188:
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.
 
==[[PHP]]==
[[Category:PHP]]
 
'''Interpreter''': PHP 5.0+
 
Exceptions were not available prior to PHP 5.0
===Define exceptions===
class MyException extends Exception
{
// Custom exception attributes & methods
}
 
===Throwing exceptions===
function throwsException()
{
throw new Exception('Exception message');
}
===Catching Exceptions===
try {
throwsException();
} catch (Exception $e) {
echo 'Caught exception: ' . $e->getMessage();
}
 
==[[Python]]==