Skip to content

Commit

Permalink
MDL-71395 block_tag_youtube: sometimes exception may have empty message
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed May 6, 2021
1 parent 1c9837a commit d7d6091
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion blocks/tag_youtube/edit_form.php
Expand Up @@ -42,19 +42,21 @@ protected function specific_definition($mform) {

// Category setting.
$categorychoices = ['0' => get_string('anycategory', 'block_tag_youtube')];
$hascategoryerror = false;
$categoryerror = '';

try {
// Get all video categories through an API call and add them to the category list.
$categorychoices += $this->block->get_categories();
} catch (Exception $e) {
$hascategoryerror = true;
$categoryerror = $e->getMessage();
}
$mform->addElement('select', 'config_category', get_string('category', 'block_tag_youtube'),
$categorychoices);
$mform->setDefault('config_category', 0);

if ($categoryerror) {
if ($hascategoryerror) {
$notification = $OUTPUT->notification(get_string('categoryerror', 'block_tag_youtube', $categoryerror),
'error');
$mform->addElement('static', 'config_category_error', '', $notification);
Expand Down

0 comments on commit d7d6091

Please sign in to comment.