Hi Toby,

On Monday 08 August 2005 15:04, Tobias Schlitt wrote:
> >  The throw an Exception when SPL disabled and an InvalidArgumentException
> >  when it is enabled.
>
> That's senseless when writing applications that shall be version
> independant. Just sticking to Exception should be fine.

No it is not, in your application you can still simply catch Exception to be 
independent of SPL since the InvalidArgumentException class extends the 
Exception class. But by using nested Exceptions you can catch them 
independently. Else you would have to catch every Exception, parse the error 
message or trace to see wether it was a problem while calling the 
function/method or some code inside the function/method went wrong.

<?php
function foo() {
    $bar = ....;
    try {
        call_with_wrong_parameter($bar);
    } catch (InvalidArgumentException $e) {
        // bad function call...
    }
}

try {
    foo();
} catch (Exception $e) {
    // any other exception
}
?>


I'd like to see something like what Sebastian suggested. And imho it wouldn't 
really be a bc-break since an uncaught exception is fatal, too.

johannes

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to