diff --git a/course/classes/category.php b/course/classes/category.php index 83ada1e0dfb..592c1017842 100644 --- a/course/classes/category.php +++ b/course/classes/category.php @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); +use core\exception\moodle_exception; /** * Class to store, cache, render and manage course category @@ -272,7 +272,7 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr if (!$coursecat) { // Course category not found. if ($strictness == MUST_EXIST) { - throw new moodle_exception('unknowncategory'); + throw new moodle_exception('unknowncategory', a: $id); } $coursecat = null; } else if (!$alwaysreturnhidden && !$coursecat->is_uservisible($user)) { diff --git a/lib/pagelib.php b/lib/pagelib.php index 2f584a98889..c5102192bab 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -25,8 +25,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); - +use core\exception\moodle_exception; use core\navigation\views\primary; use core\navigation\views\secondary; use core\navigation\output\primary as primaryoutput; @@ -2181,7 +2180,7 @@ class moodle_page { global $DB; $category = $DB->get_record('course_categories', array('id' => $categoryid)); if (!$category) { - throw new moodle_exception('unknowncategory'); + throw new moodle_exception('unknowncategory', a: $categoryid); } $this->_categories[$category->id] = $category; $parentcategoryids = explode('/', trim($category->path, '/'));