Here's a thing I've been wondering about for a while. Anybody know?
Scenario:
In the constructor in class A a RandomException can be thrown. There is also a class B which extends A, and in it's constructor it simply calls A's constructor with parrent::A();
When using the class B, I catch the exception, like so
PHP Code:
try { $var = new B(); } catch(RandomException $e) { echo "Fail!"; }
Now the question. Is the exeption in A thrown tru B and catched above, or do I need to catch and re-throw it in B, like this?
PHP Code:
class B { function B() { try { parent::A(); } catch(RandomException $e) { throw $e; } } }
|