summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-06-10 13:45:19 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-06-10 13:45:19 +0200
commit8dc6bdd96b9088b87fe8d11346338343135c77e7 (patch)
tree2f969c8b9a0572d7e4648c9ad8ff2524bdaf27af /lib
parentc0bdbd9d81eb22ded95cd7ea9b26a0c36cfa1be0 (diff)
downloadnextcloud-server-8dc6bdd96b9088b87fe8d11346338343135c77e7.tar.gz
nextcloud-server-8dc6bdd96b9088b87fe8d11346338343135c77e7.zip
clean up usage of DatabaseSetupException and catch Exceptions in entrypoints
Diffstat (limited to 'lib')
-rw-r--r--lib/response.php4
-rw-r--r--lib/setup.php24
2 files changed, 13 insertions, 15 deletions
diff --git a/lib/response.php b/lib/response.php
index 49d79fda709..674176d078b 100644
--- a/lib/response.php
+++ b/lib/response.php
@@ -11,6 +11,7 @@ class OC_Response {
const STATUS_NOT_MODIFIED = 304;
const STATUS_TEMPORARY_REDIRECT = 307;
const STATUS_NOT_FOUND = 404;
+ const STATUS_INTERNAL_SERVER_ERROR = 500;
/**
* @brief Enable response caching by sending correct HTTP headers
@@ -70,6 +71,9 @@ class OC_Response {
case self::STATUS_NOT_FOUND;
$status = $status . ' Not Found';
break;
+ case self::STATUS_INTERNAL_SERVER_ERROR;
+ $status = $status . ' Internal Server Error';
+ break;
}
header($protocol.' '.$status);
}
diff --git a/lib/setup.php b/lib/setup.php
index a63cc664dbc..71a2d13937e 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -106,12 +106,6 @@ class OC_Setup {
'hint' => $e->getHint()
);
return($error);
- } catch (Exception $e) {
- $error[] = array(
- 'error' => $e->getMessage(),
- 'hint' => ''
- );
- return($error);
}
}
elseif($dbtype == 'pgsql') {
@@ -127,7 +121,7 @@ class OC_Setup {
try {
self::setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username);
- } catch (Exception $e) {
+ } catch (DatabaseSetupException $e) {
$error[] = array(
'error' => $l->t('PostgreSQL username and/or password not valid'),
'hint' => $l->t('You need to enter either an existing account or the administrator.')
@@ -150,7 +144,7 @@ class OC_Setup {
try {
self::setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username);
- } catch (Exception $e) {
+ } catch (DatabaseSetupException $e) {
$error[] = array(
'error' => $l->t('Oracle connection could not be established'),
'hint' => $e->getMessage().' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
@@ -177,7 +171,7 @@ class OC_Setup {
try {
self::setupMSSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix);
- } catch (Exception $e) {
+ } catch (DatabaseSetupException $e) {
$error[] = array(
'error' => 'MS SQL username and/or password not valid',
'hint' => 'You need to enter either an existing account or the administrator.'
@@ -326,7 +320,7 @@ class OC_Setup {
$connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'";
$connection = @pg_connect($connection_string);
if(!$connection) {
- throw new Exception($l->t('PostgreSQL username and/or password not valid'));
+ throw new DatabaseSetupException($l->t('PostgreSQL username and/or password not valid'));
}
$e_user = pg_escape_string($dbuser);
//check for roles creation rights in postgresql
@@ -371,7 +365,7 @@ class OC_Setup {
$connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' password='$e_password'";
$connection = @pg_connect($connection_string);
if(!$connection) {
- throw new Exception($l->t('PostgreSQL username and/or password not valid'));
+ throw new DatabaseSetupException($l->t('PostgreSQL username and/or password not valid'));
}
$query = "select count(*) FROM pg_class WHERE relname='{$dbtableprefix}users' limit 1";
$result = pg_query($connection, $query);
@@ -461,9 +455,9 @@ class OC_Setup {
if(!$connection) {
$e = oci_error();
if (is_array ($e) && isset ($e['message'])) {
- throw new Exception($e['message']);
+ throw new DatabaseSetupException($e['message']);
}
- throw new Exception($l->t('Oracle username and/or password not valid'));
+ throw new DatabaseSetupException($l->t('Oracle username and/or password not valid'));
}
//check for roles creation rights in oracle
@@ -530,7 +524,7 @@ class OC_Setup {
}
$connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
if(!$connection) {
- throw new Exception($l->t('Oracle username and/or password not valid'));
+ throw new DatabaseSetupException($l->t('Oracle username and/or password not valid'));
}
$query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
$stmt = oci_parse($connection, $query);
@@ -641,7 +635,7 @@ class OC_Setup {
} else {
$entry = '';
}
- throw new Exception($l->t('MS SQL username and/or password not valid: %s', array($entry)));
+ throw new DatabaseSetupException($l->t('MS SQL username and/or password not valid: %s', array($entry)));
}
OC_Config::setValue('dbuser', $dbuser);