Example #1
0
    /**
     * Traite les erreurs (suivant le param $_CONST['POOL'][$conn]['ERROR'])
     * @param DB_driver_PDO     $connection Peut être null
     * @param DatabaseException $exception
     * @throws DatabaseException Si error_type == 'exception'
     */
    public static function handleError($connection, $exception) {
        // $connection peut être null s'il n'a pas encore été initialisé
        if (!$connection) {
            $exception->warn();
        } else {
            if ($connection->debug_type) {
                self::debug($connection, 0, $exception);
            }

            switch ($connection->error_type) {
                case 'exception':
                    throw $exception;
                    break;

                case 'silent':
                    $exception->log();
                    break;

                case 'warning':
                default:
                    $exception->warn();
            }
        }
    }