mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-30147 do not rely on dml exception type outside of dml layer
The trouble is that dml driver methods (insert, update, select) are not guaranteed to return the same exception class for various db problems and coding style issues. The recommended practice is to catch dml_exception only.
This commit is contained in:
parent
c04e80e328
commit
69ac5d478f
5 changed files with 14 additions and 14 deletions
|
@ -905,7 +905,7 @@ class dml_test extends UnitTestCase {
|
|||
$DB->execute($sql);
|
||||
$this->fail("Expecting an exception, none occurred");
|
||||
} catch (Exception $e) {
|
||||
$this->assertTrue($e instanceof dml_write_exception);
|
||||
$this->assertTrue($e instanceof dml_exception);
|
||||
}
|
||||
|
||||
// update records
|
||||
|
@ -1785,7 +1785,7 @@ class dml_test extends UnitTestCase {
|
|||
try {
|
||||
$DB->insert_record_raw($tablename, array('xxxxx' => 3, 'onechar' => 'bb'));
|
||||
$this->assertFail('Exception expected due to invalid column');
|
||||
} catch (dml_write_exception $ex) {
|
||||
} catch (dml_exception $ex) {
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue