RestFunctions::getCourseCompletionPercentage() re-throws nocriteriaset exception despite trying not to

Created on 23 May 2023, about 1 year ago
Updated 1 May 2024, about 2 months ago

Problem/Motivation

The following code always re-throws as $e->getBody() returns an array:

catch (MoodleRestException $e) {
      if (($moodle_error = $e->getBody()) && ($moodle_error == 'nocriteriaset')) {
        return NULL;
      }
      else {
        throw $e;
      }
    }

Proposed resolution

catch (MoodleRestException $e) {
      if (($moodle_error = $e->getBody()) && isset($moodle_error['errorcode']) && ($moodle_error['errorcode'] == 'nocriteriaset')) {
        return NULL;
      }
      else {
        throw $e;
      }
    }

Remaining tasks

  • Create patch
  • Add test coverage
  • Commit
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom jacktonkin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024