try-catch in throw's parent block
Posted: Wed Aug 01, 2007 8:24 am
Hi
foo2() throws an exception which gets passed to foo1().
In this code, foo1() throws exception to the try block - so its fine.
But, is it necessary to have have a try-catch-throw in foo1() too ?
Thanks
Code: Select all
class cTest
{
public function __construct()
{
}
public function foo1()
{
self::foo2();
}
public function foo2()
{
throw new Exception("error...", 456);
}
}
try
{
$o = new cTest();
$o->foo1();
}
catch (Exception $e)
{
echo $e->getMessage();
}In this code, foo1() throws exception to the try block - so its fine.
But, is it necessary to have have a try-catch-throw in foo1() too ?
Thanks