diff options
author | Joas Schilling <coding@schilljs.com> | 2024-04-10 16:07:16 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-04-12 10:30:37 +0200 |
commit | 2c6ecef90f3f3a56192dbc8c41905a81ca3b3501 (patch) | |
tree | b82898fc9238214291f76f6b9710f529f932b8f7 /lib/private/Notification | |
parent | 834bd13e282516649134269787d98e6d53e9b2d9 (diff) | |
download | nextcloud-server-2c6ecef90f3f3a56192dbc8c41905a81ca3b3501.tar.gz nextcloud-server-2c6ecef90f3f3a56192dbc8c41905a81ca3b3501.zip |
fix(notifications): Add a dedicated exception when not all fields are set while saving a notification
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Notification')
-rw-r--r-- | lib/private/Notification/Manager.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index 348ddb03df9..8bb6e1defe0 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -35,6 +35,7 @@ use OCP\Notification\IApp; use OCP\Notification\IDeferrableApp; use OCP\Notification\IDismissableNotifier; use OCP\Notification\IManager; +use OCP\Notification\IncompleteNotificationException; use OCP\Notification\INotification; use OCP\Notification\INotifier; use OCP\RichObjectStrings\IValidator; @@ -300,13 +301,11 @@ class Manager implements IManager { } /** - * @param INotification $notification - * @throws \InvalidArgumentException When the notification is not valid - * @since 8.2.0 + * {@inheritDoc} */ public function notify(INotification $notification): void { if (!$notification->isValid()) { - throw new \InvalidArgumentException('The given notification is invalid'); + throw new IncompleteNotificationException('The given notification is invalid'); } $apps = $this->getApps(); @@ -314,7 +313,11 @@ class Manager implements IManager { foreach ($apps as $app) { try { $app->notify($notification); + } catch (IncompleteNotificationException) { } catch (\InvalidArgumentException $e) { + // todo 33.0.0 Log as warning + // todo 39.0.0 Log as error + $this->logger->debug(get_class($app) . '::notify() threw \InvalidArgumentException which is deprecated. Throw \OCP\Notification\IncompleteNotificationException when the notification is incomplete for your app and otherwise handle all \InvalidArgumentException yourself.'); } } } |