From ff2d425711525c18831394c8d697d8665184eda1 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 21 Jul 2020 23:49:03 +0100 Subject: [PATCH] MDL-67394 dml: improve thrown exception when Oracle can't parse query. --- lang/en/error.php | 1 + lib/dml/oci_native_moodle_database.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lang/en/error.php b/lang/en/error.php index 5a6c4637c54..2a2eab54115 100644 --- a/lang/en/error.php +++ b/lang/en/error.php @@ -221,6 +221,7 @@ $string['ddlxmlfileerror'] = 'XML database file errors found'; $string['destinationcmnotexit'] = 'The destination course module does not exist'; $string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective or outdated, can not continue, sorry.'; $string['dmlexceptiononinstall'] = '

A database error has occurred [{$a->errorcode}].
{$a->debuginfo}

'; +$string['dmlparseexception'] = 'Error parsing SQL query'; $string['dmlreadexception'] = 'Error reading from database'; $string['dmltransactionexception'] = 'Database transaction error'; $string['dmlwriteexception'] = 'Error writing to database'; diff --git a/lib/dml/oci_native_moodle_database.php b/lib/dml/oci_native_moodle_database.php index 5bffeb69a77..ce5ae225e30 100644 --- a/lib/dml/oci_native_moodle_database.php +++ b/lib/dml/oci_native_moodle_database.php @@ -345,14 +345,16 @@ class oci_native_moodle_database extends moodle_database { /** * Prepare the statement for execution - * @throws dml_connection_exception + * * @param string $sql * @return resource + * + * @throws dml_exception */ protected function parse_query($sql) { $stmt = oci_parse($this->oci, $sql); if ($stmt == false) { - throw new dml_connection_exception('Can not parse sql query'); //TODO: maybe add better info + throw new dml_exception('dmlparseexception', null, $this->get_last_error()); } return $stmt; } -- 2.43.0