Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70489

course_delete_modules - remove try catch that hides errors in cron logs

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.0
    • None
    • MOODLE_400_STABLE

      The `course_delete_modules` adhoc task sometimes fails. But our error message is obscured by catching it which doesn't let us see the real error. 

      The try is here:

      https://github.com/moodle/moodle/blob/master/course/classes/task/course_delete_modules.php#L65

      It's right before the end of the task. So catching an exception just to throw another 'general' exception that doesn't tell us the real error is not helpful.

      With the try catch here, we get an error like this:

      Adhoc task failed: core_course\task\course_delete_modules,Coding error detected, it must be fixed by a programmer: The course module 5427738 could not be deleted. 

      Removing the try catch (just deleting those 3 lines) and rerunning the same task, we can see the real problem:

      Adhoc task failed: core_course\task\course_delete_modules,Error writing to database (ERROR: value too long for type character varying(255)
      INSERT INTO mdl_tool_recyclebin_course (courseid,section,module,name,timecreated) VALUES($1,$2,$3,$4,$5) RETURNING id

      This error is specific and we can know exactly what to do to fix this. Here we can see that our activity name is too long, because a plugin didn't enforce the 255 char limit that we are supposed to.

      There are other places in moodle where a try catch is unhelpful, eg. course_backup_task

      Am I wrong in thinking this is always going to be much more helpful? 

       

            Unassigned Unassigned
            kristianr Kristian Ringer
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.