MDL-69143 contentbank: catching Exception on file upload

This commit is contained in:
Ferran Recio 2020-08-12 16:57:17 +02:00
parent 910755acf5
commit 5132309170
2 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ use core\event\contentbank_content_created;
use core\event\contentbank_content_deleted;
use core\event\contentbank_content_viewed;
use stored_file;
use file_exception;
use Exception;
use moodle_url;
/**
@ -107,7 +107,7 @@ abstract class contenttype {
$content = $this->create_content($record);
try {
$content->import_file($file);
} catch (file_exception $e) {
} catch (Exception $e) {
$this->delete_content($content);
throw $e;
}

View File

@ -28,7 +28,7 @@ namespace core_contentbank;
use stdClass;
use context_system;
use context_user;
use file_exception;
use Exception;
use contenttype_testable\contenttype as contenttype;
/**
* Test for content bank contenttype class.
@ -283,7 +283,7 @@ class core_contenttype_contenttype_testcase extends \advanced_testcase {
try {
$content = $contenttype->upload_content($dummyfile);
$this->assertTrue(false);
} catch (file_exception $e) {
} catch (Exception $e) {
$this->assertTrue(true);
}
$this->assertEquals($cbcontents, $DB->count_records('contentbank_content'));