Changeset 4345

Show
Ignore:
Timestamp:
05/09/08 18:48:49 (14 months ago)
Author:
hansbrix
Message:

added exception handling to PDO init in connect() to avoid uncaught PDOException/convert to Doctrine_Exception

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Connection.php

    r4317 r4345  
    453453        if (extension_loaded('pdo')) { 
    454454            if (in_array($e[0], PDO::getAvailableDrivers())) { 
    455                 $this->dbh = new PDO($this->options['dsn'], $this->options['username'],  
     455                try { 
     456                    $this->dbh = new PDO($this->options['dsn'], $this->options['username'],  
    456457                                     $this->options['password'], $this->options['other']); 
    457458                                      
    458                 $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
     459                    $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
     460                } catch (PDOException $e) { 
     461                        throw new Doctrine_Connection_Exception('PDO Connection Error: ' . $e->getMessage()); 
     462                } 
    459463                $found = true; 
    460464            }