Re: Exceptions - what do they mean?



On Dec 4, 10:16 am, lawpoop <lawp...@xxxxxxxxx> wrote:

<?php

 ... whole bunch of stuff ...

$use_object = TRUE;

try {
    $myObj =& new objClass();} catch (Exception $e) {

    echo 'Caught exception: ',  $e->getMessage(), "\n";
    $use_object = FALSE;

}

if ( $use_object ) {
  ... object code goes here ...

}

 ... rest of code ...

?>

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

  • Re: Exceptions - when and why?
    ... whole bunch of stuff ... ... $myObj =& new objClass; ... object code goes here ... ...
    (php.general)
  • Re: Python equivt of __FILE__ and __LINE__
    ...     Dec ... I can use Python to do all the expression evalutaion, ... functions like Loadgenerate the approproyte object code. ... so if there is not exactly one defintion or no references, ...
    (comp.lang.python)