aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Activity
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-04-17 15:29:33 +0200
committerJoas Schilling <coding@schilljs.com>2024-04-17 15:36:42 +0200
commit9f4845e25b32b8244d8f1e5255cd325adc37cd78 (patch)
tree051f847d3ff92379fac38483f553f4ccd40a07a2 /lib/public/Activity
parent784ab6e79abdc802b30c4290729737f3ed17f73c (diff)
downloadnextcloud-server-9f4845e25b32b8244d8f1e5255cd325adc37cd78.tar.gz
nextcloud-server-9f4845e25b32b8244d8f1e5255cd325adc37cd78.zip
fix(activity): Add a dedicated exception when the filter or setting is not found
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/public/Activity')
-rw-r--r--lib/public/Activity/Exceptions/FilterNotFoundException.php48
-rw-r--r--lib/public/Activity/Exceptions/SettingNotFoundException.php48
-rw-r--r--lib/public/Activity/IManager.php8
3 files changed, 102 insertions, 2 deletions
diff --git a/lib/public/Activity/Exceptions/FilterNotFoundException.php b/lib/public/Activity/Exceptions/FilterNotFoundException.php
new file mode 100644
index 00000000000..5988bcc6200
--- /dev/null
+++ b/lib/public/Activity/Exceptions/FilterNotFoundException.php
@@ -0,0 +1,48 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com>
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * @since 30.0.0
+ */
+class FilterNotFoundException extends \InvalidArgumentException {
+ /**
+ * @since 30.0.0
+ */
+ public function __construct(
+ protected string $filter,
+ ) {
+ parent::__construct('Filter ' . $filter . ' not found');
+ }
+
+ /**
+ * @since 30.0.0
+ */
+ public function getFilterId(): string {
+ return $this->filter;
+ }
+}
diff --git a/lib/public/Activity/Exceptions/SettingNotFoundException.php b/lib/public/Activity/Exceptions/SettingNotFoundException.php
new file mode 100644
index 00000000000..e4b87266143
--- /dev/null
+++ b/lib/public/Activity/Exceptions/SettingNotFoundException.php
@@ -0,0 +1,48 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com>
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * @since 30.0.0
+ */
+class SettingNotFoundException extends \InvalidArgumentException {
+ /**
+ * @since 30.0.0
+ */
+ public function __construct(
+ protected string $setting,
+ ) {
+ parent::__construct('Setting ' . $setting . ' not found');
+ }
+
+ /**
+ * @since 30.0.0
+ */
+ public function getSettingId(): string {
+ return $this->setting;
+ }
+}
diff --git a/lib/public/Activity/IManager.php b/lib/public/Activity/IManager.php
index 6de21d4347e..3d364874e5e 100644
--- a/lib/public/Activity/IManager.php
+++ b/lib/public/Activity/IManager.php
@@ -28,7 +28,9 @@ declare(strict_types=1);
*/
namespace OCP\Activity;
+use OCP\Activity\Exceptions\FilterNotFoundException;
use OCP\Activity\Exceptions\IncompleteActivityException;
+use OCP\Activity\Exceptions\SettingNotFoundException;
/**
* Interface IManager
@@ -95,8 +97,9 @@ interface IManager {
/**
* @param string $id
* @return IFilter
- * @throws \InvalidArgumentException when the filter was not found
+ * @throws FilterNotFoundException when the filter was not found
* @since 11.0.0
+ * @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
*/
public function getFilterById(string $id): IFilter;
@@ -127,8 +130,9 @@ interface IManager {
/**
* @param string $id
* @return ActivitySettings
- * @throws \InvalidArgumentException when the setting was not found
+ * @throws SettingNotFoundException when the setting was not found
* @since 11.0.0
+ * @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
*/
public function getSettingById(string $id): ActivitySettings;