diff --git a/content/updateArticle.php b/content/updateArticle.php index 90e80de..9c66ec8 100644 --- a/content/updateArticle.php +++ b/content/updateArticle.php @@ -53,6 +53,11 @@ include_once 'php/controller/showArticle-controller.php'; Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
+ + + diff --git a/php/controller/updateArticle-controller.php b/php/controller/updateArticle-controller.php index 34493ac..7546817 100644 --- a/php/controller/updateArticle-controller.php +++ b/php/controller/updateArticle-controller.php @@ -82,7 +82,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { $article->setTags($cleanedTags); $articleManager->updateArticle($id ,$article, $author); } catch (Exception $e){ - $_SESSION["message"] = "internal_error"; + $_SESSION["message"] = $e->getMessage(); header("location: ../../index.php?pfad=updateArticle"); exit(); } diff --git a/php/model/ArticleManagerDAO.php b/php/model/ArticleManagerDAO.php index 46c72a3..72a4a64 100644 --- a/php/model/ArticleManagerDAO.php +++ b/php/model/ArticleManagerDAO.php @@ -3,6 +3,7 @@ require_once "Article.php"; class NotFoundException extends Exception {} class UnauthorizedAccessException extends Exception {} +class InternalServerErrorException extends Exception {} /** * Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten. @@ -33,6 +34,7 @@ interface ArticleManagerDAO * @param $author * @return void * + * @throws InternalServerErrorException * @throws NotFoundException * @throws UnauthorizedAccessException * / diff --git a/php/model/LocalArticleManager.php b/php/model/LocalArticleManager.php index c9de471..c1cbf39 100644 --- a/php/model/LocalArticleManager.php +++ b/php/model/LocalArticleManager.php @@ -61,16 +61,16 @@ class LocalArticleManager implements ArticleManagerDAO { $this->saveArticle($articles); } - + public function updateArticle($id, $article, $author) { if (empty($article)) { - throw new InvalidArgumentException("Der Beitrag darf nicht leer sein."); + throw new InternalServerErrorException("internal_error"); } // Berechtigungsprüfung: if ($article->getAuthor() !== $author) { - throw new UnauthorizedAccessException("Sie sind nicht berechtigt, diesen Artikel zu bearbeiten."); + throw new UnauthorizedAccessException("unauthorized_access"); } // Beitrag aktualisieren: @@ -97,8 +97,7 @@ class LocalArticleManager implements ArticleManagerDAO { if ($updated) { $this->saveArticle($articles); } else { - throw new NotFoundException("Ein Artikel mit der ID". $id . " wurde nicht gefunden."); - + throw new NotFoundException("missing_id"); } }