diff --git a/backup/moodle2/restore_format_topcoll_plugin.class.php b/backup/moodle2/restore_format_topcoll_plugin.class.php index f392160..0f2525a 100644 --- a/backup/moodle2/restore_format_topcoll_plugin.class.php +++ b/backup/moodle2/restore_format_topcoll_plugin.class.php @@ -87,7 +87,7 @@ public function process_topcoll($data) { $data->courseid = $this->task->get_courseid(); if (!($course = $DB->get_record('course', array('id' => $data->courseid)))) { - print_error('invalidcourseid', 'error'); + throw new \moodle_exception('invalidcourseid', 'error'); } // From /course/view.php. $courseformat = course_get_format($course); diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 3903df2..e8a25fb 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -663,7 +663,7 @@ public function single_section_page($displaysection) { if (!($thissection = $modinfo->get_section_info($displaysection))) { /* This section doesn't exist or is not available for the user. We actually already check this in course/view.php but just in case exit from this function as well. */ - print_error('unknowncoursesection', 'error', course_get_url($course), + throw new \moodle_exception('unknowncoursesection', 'error', course_get_url($course), format_string($course->fullname)); } diff --git a/settopcollpref.php b/settopcollpref.php index a47fed5..466e1dd 100644 --- a/settopcollpref.php +++ b/settopcollpref.php @@ -38,7 +38,7 @@ // Get the name of the preference to update, and check that it is allowed. $name = required_param('pref', PARAM_RAW); if (!isset($USER->ajax_updatable_user_prefs[$name])) { - print_error('notallowedtoupdateprefremotely'); + throw new \moodle_exception('notallowedtoupdateprefremotely'); } // Get and set the value. @@ -46,7 +46,7 @@ // Update. if ($value) { if (!set_user_preference($name, $value)) { - print_error('errorsettinguserpref'); + throw new \moodle_exception('errorsettinguserpref'); } echo 'OK'; } else {