diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 3025b32837d..236fa775907 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -14,8 +14,10 @@ return array( 'OCP\\Accounts\\PropertyDoesNotExistException' => $baseDir . '/lib/public/Accounts/PropertyDoesNotExistException.php', 'OCP\\Accounts\\UserUpdatedEvent' => $baseDir . '/lib/public/Accounts/UserUpdatedEvent.php', 'OCP\\Activity\\ActivitySettings' => $baseDir . '/lib/public/Activity/ActivitySettings.php', + 'OCP\\Activity\\Exceptions\\FilterNotFoundException' => $baseDir . '/lib/public/Activity/Exceptions/FilterNotFoundException.php', 'OCP\\Activity\\Exceptions\\IncompleteActivityException' => $baseDir . '/lib/public/Activity/Exceptions/IncompleteActivityException.php', 'OCP\\Activity\\Exceptions\\InvalidValueException' => $baseDir . '/lib/public/Activity/Exceptions/InvalidValueException.php', + 'OCP\\Activity\\Exceptions\\SettingNotFoundException' => $baseDir . '/lib/public/Activity/Exceptions/SettingNotFoundException.php', 'OCP\\Activity\\Exceptions\\UnknownActivityException' => $baseDir . '/lib/public/Activity/Exceptions/UnknownActivityException.php', 'OCP\\Activity\\IConsumer' => $baseDir . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => $baseDir . '/lib/public/Activity/IEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index d1125e6231d..e6035fd13b2 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -47,8 +47,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Accounts\\PropertyDoesNotExistException' => __DIR__ . '/../../..' . '/lib/public/Accounts/PropertyDoesNotExistException.php', 'OCP\\Accounts\\UserUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/Accounts/UserUpdatedEvent.php', 'OCP\\Activity\\ActivitySettings' => __DIR__ . '/../../..' . '/lib/public/Activity/ActivitySettings.php', + 'OCP\\Activity\\Exceptions\\FilterNotFoundException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/FilterNotFoundException.php', 'OCP\\Activity\\Exceptions\\IncompleteActivityException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/IncompleteActivityException.php', 'OCP\\Activity\\Exceptions\\InvalidValueException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/InvalidValueException.php', + 'OCP\\Activity\\Exceptions\\SettingNotFoundException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/SettingNotFoundException.php', 'OCP\\Activity\\Exceptions\\UnknownActivityException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/UnknownActivityException.php', 'OCP\\Activity\\IConsumer' => __DIR__ . '/../../..' . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => __DIR__ . '/../../..' . '/lib/public/Activity/IEvent.php', diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 3458ea041c3..7f95771294a 100644 --- a/lib/private/Activity/Manager.php +++ b/lib/private/Activity/Manager.php @@ -29,7 +29,9 @@ namespace OC\Activity; use OCP\Activity\ActivitySettings; +use OCP\Activity\Exceptions\FilterNotFoundException; use OCP\Activity\Exceptions\IncompleteActivityException; +use OCP\Activity\Exceptions\SettingNotFoundException; use OCP\Activity\IConsumer; use OCP\Activity\IEvent; use OCP\Activity\IFilter; @@ -198,10 +200,7 @@ class Manager implements IManager { } /** - * @param string $id - * @return IFilter - * @throws \InvalidArgumentException when the filter was not found - * @since 11.0.0 + * {@inheritDoc} */ public function getFilterById(string $id): IFilter { $filters = $this->getFilters(); @@ -210,7 +209,7 @@ class Manager implements IManager { return $filters[$id]; } - throw new \InvalidArgumentException('Requested filter does not exist'); + throw new FilterNotFoundException($id); } /** @var string[] */ @@ -286,10 +285,7 @@ class Manager implements IManager { } /** - * @param string $id - * @return ActivitySettings - * @throws \InvalidArgumentException when the setting was not found - * @since 11.0.0 + * {@inheritDoc} */ public function getSettingById(string $id): ActivitySettings { $settings = $this->getSettings(); @@ -298,7 +294,7 @@ class Manager implements IManager { return $settings[$id]; } - throw new \InvalidArgumentException('Requested setting does not exist'); + throw new SettingNotFoundException($id); } 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 @@ + + * + * @author Joas Schilling + * + * @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 . + * + */ + +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 @@ + + * + * @author Joas Schilling + * + * @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 . + * + */ + +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;