Skip to content

Commit

Permalink
MDL-16930 ddl - exceptions cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 18, 2008
1 parent 0487f9e commit 6d89eff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
30 changes: 0 additions & 30 deletions lib/ddl/database_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1003,34 +1003,4 @@ public function check_database_schema(xmldb_structure $schema) {
}


/**
* DDL exception class, use instead of error() and "return false;" in ddl code.
*/
class ddl_exception extends moodle_exception {
function __construct($errorcode, $a=NULL, $debuginfo=null) {
parent::__construct($errorcode, '', '', $a, $debuginfo);
}
}

/**
* Table does not exist problem exception
*/
class ddl_table_missing_exception extends ddl_exception {
function __construct($tablename, $debuginfo=null) {
parent::__construct('ddltablenotexist', $tablename, $debuginfo);
}
}

/**
* Table does not exist problem exception
*/
class ddl_field_missing_exception extends ddl_exception {
function __construct($fieldname, $tablename, $debuginfo=null) {
$a = new object();
$a->fieldname = $fieldname;
$a->tablename = $tablename;
parent::__construct('ddlfieldnotexist', $a, $debuginfo);
}
}

?>
31 changes: 31 additions & 0 deletions lib/ddllib.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,34 @@
require_once($CFG->libdir.'/ddl/sql_generator.php');
require_once($CFG->libdir.'/ddl/database_manager.php');



/**
* DDL exception class, use instead of error() and "return false;" in ddl code.
*/
class ddl_exception extends moodle_exception {
function __construct($errorcode, $a=NULL, $debuginfo=null) {
parent::__construct($errorcode, '', '', $a, $debuginfo);
}
}

/**
* Table does not exist problem exception
*/
class ddl_table_missing_exception extends ddl_exception {
function __construct($tablename, $debuginfo=null) {
parent::__construct('ddltablenotexist', $tablename, $debuginfo);
}
}

/**
* Table does not exist problem exception
*/
class ddl_field_missing_exception extends ddl_exception {
function __construct($fieldname, $tablename, $debuginfo=null) {
$a = new object();
$a->fieldname = $fieldname;
$a->tablename = $tablename;
parent::__construct('ddlfieldnotexist', $a, $debuginfo);
}
}

0 comments on commit 6d89eff

Please sign in to comment.