Re: Exceptions - when and why?



Now that I've chomped this over a bit, I could do something like:

<?php

... whole bunch of stuff ...

try {
$myObj =& new objClass();
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}

if ( $myObj-> useable == 1 ) {
... object code goes here ...

}

... rest of code ...

?>

I guess the whole reason this seem inelegant to me is that I would
like to do something like:

try {
$myObj =& new objClass();
} if ( catch (Exception $e) ) {
echo 'Caught exception: ', $e->getMessage(), "\n";
} else {
... object code goes here ...

}

Thoughts...?
.



Relevant Pages