diff options
-rw-r--r-- | lib/private/db/adapter.php | 10 | ||||
-rw-r--r-- | lib/private/db/adaptersqlite.php | 18 | ||||
-rw-r--r-- | lib/private/db/statementwrapper.php | 16 |
3 files changed, 31 insertions, 13 deletions
diff --git a/lib/private/db/adapter.php b/lib/private/db/adapter.php index 972008776f6..58b3514b922 100644 --- a/lib/private/db/adapter.php +++ b/lib/private/db/adapter.php @@ -43,6 +43,7 @@ class Adapter { * insert the @input values when they do not exist yet * @param string $table name * @param array $input key->value pair, key has to be sanitized properly + * @throws \OC\HintException * @return int count of inserted rows */ public function insertIfNotExist($table, $input) { @@ -70,8 +71,13 @@ class Adapter { $entry = 'DB Error: "'.$e->getMessage() . '"<br />'; $entry .= 'Offending command was: ' . $query.'<br />'; \OC_Log::write('core', $entry, \OC_Log::FATAL); - error_log('DB error: ' . $entry); - \OC_Template::printErrorPage( $entry ); + $l = \OC::$server->getL10N('lib'); + throw new \OC\HintException( + $l->t('Database Error'), + $l->t('Please contact your system administrator.'), + 0, + $e + ); } } } diff --git a/lib/private/db/adaptersqlite.php b/lib/private/db/adaptersqlite.php index 3471fcf4042..c5dfa85aaac 100644 --- a/lib/private/db/adaptersqlite.php +++ b/lib/private/db/adaptersqlite.php @@ -41,8 +41,13 @@ class AdapterSqlite extends Adapter { $entry = 'DB Error: "'.$e->getMessage() . '"<br />'; $entry .= 'Offending command was: ' . $query . '<br />'; \OC_Log::write('core', $entry, \OC_Log::FATAL); - error_log('DB error: '.$entry); - \OC_Template::printErrorPage( $entry ); + $l = \OC::$server->getL10N('lib'); + throw new \OC\HintException( + $l->t('Database Error'), + $l->t('Please contact your system administrator.'), + 0, + $e + ); } if ($stmt->fetchColumn() === '0') { @@ -60,8 +65,13 @@ class AdapterSqlite extends Adapter { $entry = 'DB Error: "'.$e->getMessage() . '"<br />'; $entry .= 'Offending command was: ' . $query.'<br />'; \OC_Log::write('core', $entry, \OC_Log::FATAL); - error_log('DB error: ' . $entry); - \OC_Template::printErrorPage( $entry ); + $l = \OC::$server->getL10N('lib'); + throw new \OC\HintException( + $l->t('Database Error'), + $l->t('Please contact your system administrator.'), + 0, + $e + ); } return $result; diff --git a/lib/private/db/statementwrapper.php b/lib/private/db/statementwrapper.php index ad63de98e93..a85c0167e0b 100644 --- a/lib/private/db/statementwrapper.php +++ b/lib/private/db/statementwrapper.php @@ -64,7 +64,7 @@ class OC_DB_StatementWrapper { } else { $result = $this->statement->execute(); } - + if ($result === false) { return false; } @@ -158,14 +158,16 @@ class OC_DB_StatementWrapper { OC_Log::write('core', $entry, OC_Log::FATAL); OC_User::setUserId(null); - // send http status 503 - header('HTTP/1.1 503 Service Temporarily Unavailable'); - header('Status: 503 Service Temporarily Unavailable'); - OC_Template::printErrorPage('Failed to connect to database'); - die ($entry); + $l = \OC::$server->getL10N('lib'); + throw new \OC\HintException( + $l->t('Database Error'), + $l->t('Please contact your system administrator.'), + 0, + $e + ); } } - + /** * provide an alias for fetch * |