Re: Exception handling in PHP

From: Date: Thu, 07 Feb 2008 10:54:39 +0000
Subject: Re: Exception handling in PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-268861@lists.php.net to get a copy of this message
// ...
That's from memory, so there may be a few errors.
Seems there was. Try this: class DBException extends Exception {} try {
    $connection = mysql_connect(...);
    if (!$connection) {
        throw new DBException('Failed to connect to database');
    }
// Database exception handling code } catch (DBException $e) {
    // ...
// Generic Exception handling code (The Exception class is // built in to PHP) } catch (Exception $e) {
    // ...
} -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software for £299 hosted for you - no installation, no maintenance, new features automatic and free ** New Helpdesk demo now available **

« previous php.general (#268861) next »