FIX Throw Exception instead of user_error when failing to select schema or connect to DB

This commit is contained in:
Robbie Averill 2017-11-30 15:15:20 +13:00
parent a401f7ad24
commit 276ee9aab2
1 changed files with 3 additions and 2 deletions

View File

@ -306,6 +306,7 @@ class PostgreSQLDatabase extends Database
* @param int|boolean $errorLevel The level of error reporting to enable for
* the query, or false if no error should be raised
* @return boolean Flag indicating success
* @throws Exception If the schema doesn't exist
*/
public function setSchema($schema, $create = false, $errorLevel = E_USER_ERROR)
{
@ -313,7 +314,7 @@ class PostgreSQLDatabase extends Database
// Check DB creation permisson
if (!$create) {
if ($errorLevel !== false) {
user_error("Schema $schema does not exist", $errorLevel);
throw new Exception("Schema $schema does not exist");
}
$this->schema = null;
return false;
@ -756,7 +757,7 @@ class PostgreSQLDatabase extends Database
// Check DB creation permisson
if (!$create) {
if ($errorLevel !== false) {
user_error("Attempted to connect to non-existing database \"$name\"", $errorLevel);
throw new Exception('Attempted to connect to non-existing database "$name"');
}
// Unselect database
$this->connector->unloadDatabase();