]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Add `InvalidFieldType` exception
authorElizabeth Danzberger <lizzy7128@tutanota.de>
Fri, 12 Jul 2024 18:36:40 +0000 (14:36 -0400)
committerJulius Härtl <jus@bitgrid.net>
Thu, 25 Jul 2024 09:11:39 +0000 (11:11 +0200)
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
lib/public/Files/Template/Field.php
lib/public/Files/Template/InvalidFieldtypeException.php [new file with mode: 0644]

index 9437563cce832662dc67076adad67b36f6239bc6..86f6a3e72fa182ae8eaded697ed2079a18f04702 100644 (file)
@@ -7,6 +7,8 @@
 
 namespace OCP\Files\Template;
 
+use OCP\Files\Template\InvalidFieldTypeException;
+
 class Field implements \JsonSerializable {
        private int $index;
        private string $content;
@@ -26,7 +28,7 @@ class Field implements \JsonSerializable {
                        $this->type = $type;
                } else {
                        // TODO: Throw a proper enum with descriptive message
-                       $this->type = FieldType::tryFrom($type) ?? throw new \Exception();
+                       $this->type = FieldType::tryFrom($type) ?? throw new InvalidFieldTypeException();
                }
        }
 
diff --git a/lib/public/Files/Template/InvalidFieldtypeException.php b/lib/public/Files/Template/InvalidFieldtypeException.php
new file mode 100644 (file)
index 0000000..a0c5297
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Files\Template;
+
+/**
+ * Exception for invalid template field type
+ * @since 30.0.0
+ */
+class InvalidFieldTypeException extends \Exception {
+}