summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2012-12-08 03:42:01 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2012-12-08 03:42:01 -0800
commita84ae04c17df4891664d09c46b6294b2c6693350 (patch)
tree2e8b0985215468ad7cee88284005ef83b1c39641 /lib
parent2ca72d0da717be6278aed5c0df48b2127f42c709 (diff)
parent65e4dc183c8424cc31f67ccddc2e4d6df5b56379 (diff)
downloadnextcloud-server-a84ae04c17df4891664d09c46b6294b2c6693350.tar.gz
nextcloud-server-a84ae04c17df4891664d09c46b6294b2c6693350.zip
Merge pull request #762 from owncloud/database_exception
dont handle database exception in OC_DB
Diffstat (limited to 'lib')
-rw-r--r--lib/db.php25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/db.php b/lib/db.php
index e63a7a20c81..6524db7581a 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -20,6 +20,19 @@
*
*/
+class DatabaseException extends Exception{
+ private $query;
+
+ public function __construct($message, $query){
+ parent::__construct($message);
+ $this->query = $query;
+ }
+
+ public function getQuery(){
+ return $this->query;
+ }
+}
+
/**
* This class manages the access to the database. It basically is a wrapper for
* MDB2 with some adaptions.
@@ -320,21 +333,13 @@ class OC_DB {
// Die if we have an error (error means: bad query, not 0 results!)
if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.htmlentities($query).'<br />';
- OC_Log::write('core', $entry, OC_Log::FATAL);
- error_log('DB error: '.$entry);
- OC_Template::printErrorPage( $entry );
+ throw new DatabaseException($result->getMessage(), $query);
}
}else{
try{
$result=self::$connection->prepare($query);
}catch(PDOException $e) {
- $entry = 'DB Error: "'.$e->getMessage().'"<br />';
- $entry .= 'Offending command was: '.htmlentities($query).'<br />';
- OC_Log::write('core', $entry, OC_Log::FATAL);
- error_log('DB error: '.$entry);
- OC_Template::printErrorPage( $entry );
+ throw new DatabaseException($e->getMessage(), $query);
}
$result=new PDOStatementWrapper($result);
}