Handling exception question



Hello,

I have code like this:

class MyException extends Exception {}

function x() {
try {
throw new MyException()
} catch (Exception $e) {
echo 'Exception catched';
exit;
}

try {
x();
} catch (MyException $e) {
echo 'MyException catched';
exit;
}



I cannot understand why this code catches Exception instead of
MyException? Can you please tell me what is wrong with it?

Best rgrds,
Paul

.


Quantcast