Skip to content

Commit

Permalink
course-delete error reporting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mi7chal committed Aug 28, 2024
1 parent a434b70 commit 102c511
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Moosh/Command/Moodle39/Course/CourseDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ public function execute()

if ($course instanceof \stdClass) {
try {
print "About to delete course id={$course->id}; shortname={$course->shortname}; category id={$course->category}";
delete_course($course);
print "About to delete course id={$course->id}; shortname={$course->shortname}; category id={$course->category}\n";

$wasDeleted = delete_course($course);

if($wasDeleted) {
print "Course $course->id has been deleted.\n";
} else {
print "Course with id {$course->id} cant't be deleted.\n";
}
} catch (Exception $e) {
print get_class($e) . " thrown for courseid={$course->id} within the exception handler. Message: " . $e->getMessage() . " on line " . $e->getLine();
}
Expand Down

0 comments on commit 102c511

Please sign in to comment.