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

course_delete_modules - remove try catch that hides errors in cron logs

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.0
    • Fix Version/s: None
    • Labels:
      None
    • Affected Branches:
      MOODLE_400_STABLE

      Description

      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? 

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              kristianr Kristian Ringer
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: