Updated db setup to catch PDOExceptions
This commit is contained in:
parent
3966a7aa36
commit
270e84e9d8
|
@ -44,12 +44,7 @@ class DatabaseSetup extends Setup {
|
||||||
. ";user=" . $this->user . ";password=" . $this->pass);
|
. ";user=" . $this->user . ";password=" . $this->pass);
|
||||||
$err = self::$dbh->errorInfo();
|
$err = self::$dbh->errorInfo();
|
||||||
if ($err[1] != null) {
|
if ($err[1] != null) {
|
||||||
throw new AirtimeDatabaseException("Couldn't establish a connection to the database!",
|
throw new PDOException();
|
||||||
array(
|
|
||||||
self::DB_NAME,
|
|
||||||
self::DB_USER,
|
|
||||||
self::DB_PASS,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +56,7 @@ class DatabaseSetup extends Setup {
|
||||||
* @throws AirtimeDatabaseException
|
* @throws AirtimeDatabaseException
|
||||||
*/
|
*/
|
||||||
public function runSetup() {
|
public function runSetup() {
|
||||||
|
try {
|
||||||
$this->setNewDatabaseConnection("postgres");
|
$this->setNewDatabaseConnection("postgres");
|
||||||
if ($this->checkDatabaseExists()) {
|
if ($this->checkDatabaseExists()) {
|
||||||
$this->installDatabaseTables();
|
$this->installDatabaseTables();
|
||||||
|
@ -69,6 +65,15 @@ class DatabaseSetup extends Setup {
|
||||||
$this->createDatabase();
|
$this->createDatabase();
|
||||||
$this->installDatabaseTables();
|
$this->installDatabaseTables();
|
||||||
}
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
throw new AirtimeDatabaseException("Couldn't establish a connection to the database! "
|
||||||
|
. "Please check your credentials and try again.",
|
||||||
|
array(
|
||||||
|
self::DB_NAME,
|
||||||
|
self::DB_USER,
|
||||||
|
self::DB_PASS,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$this->writeToTemp();
|
$this->writeToTemp();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue