Re: Exceptions and Errors

From: Date: Fri, 16 Apr 2004 07:08:46 +0000
Subject: Re: Exceptions and Errors
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-9248@lists.php.net to get a copy of this message
I'm not sure how much Java code you have seen/written but this tends to lead to a million of empty try/catch statements which only lead to a false sense of security because in practice, you are barely handling any exceptions. At 11:05 AM 4/16/2004 +1200, Jevon Wright wrote:
Guys, I'm am not for forcing people to use exceptions. I agree that we should make PHP another Java exceptions from hell (especially with their exception declarations in function prototypes which is horrible). I'm just saying, that some extensions might benefit from exceptions and the extension author should be allowed to choose (as long as he doesn't break BC). But the exception declarations ensure that you don't accidentally catch an Exception in the wrong place, eg. function add($amount) {
    add_money($amount) and log() or throw exception;
} function move($amount) {
    $from->add(-$amount);
    # It is *not* obvious here that this can fail and execution
    # might stop here! Very dangerous!
    $to->add($amount);
} function transactions() {
    foreach ($transaction)
    try { move($transaction->amount); } catch ...
} You'd have to go function move($amount) throws SomeException, forcing the developer to handle Exceptions at the soonest possible point... (I'm a fan of it.) Jevon -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#9248) next »