]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17129 basic dml exceptions
authorskodak <skodak>
Tue, 4 Nov 2008 21:50:13 +0000 (21:50 +0000)
committerskodak <skodak>
Tue, 4 Nov 2008 21:50:13 +0000 (21:50 +0000)
lang/en_utf8/error.php
lib/dml/moodle_database.php
lib/dmllib.php
lib/setuplib.php

index ae68bbcaa1e884688df3187068afed4714bda4ea..0863bfeaa72295733c2f3b934e5a00d99eb3e03b 100644 (file)
@@ -190,6 +190,8 @@ $string['ddltablealreadyexists'] = 'Table \"$a\" already exists';
 $string['ddltablenotexist'] = 'Table \"$a\" does not exist';
 $string['ddlunknownerror'] = 'Unknown DDL library error';
 $string['ddlxmlfileerror'] = 'XML database file errors found';
+$string['dmlreadexception'] = 'Error reading from database';
+$string['dmlwriteexception'] = 'Error writing to database';
 $string['destinationcmnotexit'] = 'The destination course module does not exist';
 $string['downloadedfilecheckfailed'] = 'Downloaded file check failed';
 $string['duplicateusername'] = 'Duplicate username - skipping record';
index 2bea51aab113739a4e19bb821c3c3e9014e4e944..851d15c3824dea302627d89763d075cafc579ac5 100644 (file)
@@ -294,7 +294,7 @@ abstract class moodle_database {
      * @param mixed $obj optional library specific object
      */
     protected function report_error($sql, array $params=null, $obj=null) {
-        debugging($this->get_last_error() .'<br /><br />'. s($sql).'<br />['.s(var_export($params, true)).']');
+        debugging(s($this->get_last_error()).'<br /><br />'.s($sql).'<br />['.s(var_export($params, true)).']');
     }
 
     /**
index e193c0b752e9a3dcb073ffd97e4db018de8e6afe..bd6e0c6c326a65e07dc05836546b0d205790471a 100644 (file)
@@ -46,6 +46,40 @@ class dml_exception extends moodle_exception {
     }
 }
 
+/**
+ * DML read exception - triggered by SQL syntax errors, missing tables, etc.
+ */
+class dml_read_exception extends dml_exception {
+    public $error;
+    public $sql;
+    public $params;
+
+    function __construct($error, $sql=null, array $params=null) {
+        $this->error  = $error;
+        $this->sql    = $sql;
+        $this->params = $params;
+        $errorinfo = s($error).'<br /><br />'.s($sql).'<br />['.s(var_export($params, true)).']';
+        parent::__construct('dmlreadexception', NULL, $errorinfo);
+    }
+}
+
+/**
+ * DML read exception - triggered by SQL syntax errors, missing tables, etc.
+ */
+class dml_write_exception extends dml_exception {
+    public $error;
+    public $sql;
+    public $params;
+
+    function __construct($error, $sql=null, array $params=null) {
+        $this->error  = $error;
+        $this->sql    = $sql;
+        $this->params = $params;
+        $errorinfo = s($error).'<br /><br />'.s($sql).'<br />['.s(var_export($params, true)).']';
+        parent::__construct('dmlwriteexception', NULL, $errorinfo);
+    }
+}
+
 /**
  * Sets up global $DB moodle_database instance
  * @return void
index 1a75ada4ccdc1c3331375d50b168db2c58473cb9..5323e6883a53eb57dd9237d56fc2c43c5e59e721 100644 (file)
@@ -45,7 +45,7 @@ class moodle_exception extends Exception {
 }
 
 /**
- * Exception indicating programming error, must be fixed by a programeer.
+ * Exception indicating programming error, must be fixed by a programer.
  */
 class coding_exception extends moodle_exception {