From e38247449aa8b5fc41812c30d55a5d4b5aedbcec Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 21 Apr 2021 16:19:21 +0200 Subject: [PATCH] MDL-71395 block_tag_youtube: sometimes exception may have empty message --- blocks/tag_youtube/edit_form.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blocks/tag_youtube/edit_form.php b/blocks/tag_youtube/edit_form.php index 75e5c0dc623..16a83077435 100644 --- a/blocks/tag_youtube/edit_form.php +++ b/blocks/tag_youtube/edit_form.php @@ -42,19 +42,21 @@ class block_tag_youtube_edit_form extends block_edit_form { // 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);