Skip to content
Snippets Groups Projects
Commit 0d78ac7d authored by Adam Nagy's avatar Adam Nagy
Browse files

Throw exception if document or file can't be loaded.

parent bed18b44
Branches
Tags 1.0.0-alpha1
No related merge requests found
Pipeline #313989 passed with warnings
...@@ -196,15 +196,13 @@ final class SummarizeDocument extends AiCKEditorPluginBase { ...@@ -196,15 +196,13 @@ final class SummarizeDocument extends AiCKEditorPluginBase {
$document = $this->entityTypeManager->getStorage('media')->load($values['plugin_config']['document']); $document = $this->entityTypeManager->getStorage('media')->load($values['plugin_config']['document']);
if (!$document instanceof MediaInterface) { if (!$document instanceof MediaInterface) {
$this->logger->error('Could not load the selected document.'); throw new \Exception('Could not load the selected document.');
return $form['plugin_config']['response_text']['#value'] = 'Could not load the selected document.';
} }
$file_id = $document->getSource()->getSourceFieldValue($document); $file_id = $document->getSource()->getSourceFieldValue($document);
$file = $this->entityTypeManager->getStorage('file')->load($file_id); $file = $this->entityTypeManager->getStorage('file')->load($file_id);
if (!$file instanceof FileInterface) { if (!$file instanceof FileInterface) {
$this->logger->error('Could not load the file from the selected document.'); throw new \Exception('Could not load the file from the selected document.');
return $form['plugin_config']['response_text']['#value'] = 'Could not load the file from the selected document.';
} }
$parser = new Parser(); $parser = new Parser();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment