From 0d78ac7d7265e6317429a9c221c2135f87b7468f Mon Sep 17 00:00:00 2001
From: nagyad <joevagyok@gmail.com>
Date: Fri, 18 Oct 2024 18:36:49 +0200
Subject: [PATCH] Throw exception if document or file can't be loaded.

---
 src/Plugin/AiCKEditor/SummarizeDocument.php | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/Plugin/AiCKEditor/SummarizeDocument.php b/src/Plugin/AiCKEditor/SummarizeDocument.php
index 80e0b2e..cd49ded 100755
--- a/src/Plugin/AiCKEditor/SummarizeDocument.php
+++ b/src/Plugin/AiCKEditor/SummarizeDocument.php
@@ -196,15 +196,13 @@ final class SummarizeDocument extends AiCKEditorPluginBase {
 
     $document = $this->entityTypeManager->getStorage('media')->load($values['plugin_config']['document']);
     if (!$document instanceof MediaInterface) {
-      $this->logger->error('Could not load the selected document.');
-      return $form['plugin_config']['response_text']['#value'] = 'Could not load the selected document.';
+      throw new \Exception('Could not load the selected document.');
     }
 
     $file_id = $document->getSource()->getSourceFieldValue($document);
     $file = $this->entityTypeManager->getStorage('file')->load($file_id);
     if (!$file instanceof FileInterface) {
-      $this->logger->error('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.';
+      throw new \Exception('Could not load the file from the selected document.');
     }
 
     $parser = new Parser();
-- 
GitLab