fix: Add `InvalidFieldType` exception

Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
pull/46383/head
Elizabeth Danzberger 2024-07-12 14:36:40 +07:00 committed by Julius Härtl
parent 49cc5beccc
commit aa63121197
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 18 additions and 1 deletions

@ -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();
}
}

@ -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 {
}