summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-06-25 16:09:38 +0200
committerGitHub <noreply@github.com>2024-06-25 16:09:38 +0200
commitad2fa3724db6edc88a4997678b95e0d90b8bc7fa (patch)
treeae9a2d5e1b97dde8673f75aaef18a00e58fa4bbd /apps/dav
parent565809febaa1b2475245f400e53d6f86b80ff630 (diff)
parent8130968a352bcf66606a076598fa4a58a291bc6d (diff)
downloadnextcloud-server-ad2fa3724db6edc88a4997678b95e0d90b8bc7fa.tar.gz
nextcloud-server-ad2fa3724db6edc88a4997678b95e0d90b8bc7fa.zip
Merge pull request #46095 from nextcloud/techdebt/44770/migrate-server-notifier-to-new-exceptions
feat(notifications): Migrate server INotifiers to new exceptions
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/Reminder/Notifier.php7
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php5
2 files changed, 7 insertions, 5 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/Notifier.php b/apps/dav/lib/CalDAV/Reminder/Notifier.php
index 8863c165be1..f3c784ea21f 100644
--- a/apps/dav/lib/CalDAV/Reminder/Notifier.php
+++ b/apps/dav/lib/CalDAV/Reminder/Notifier.php
@@ -17,6 +17,7 @@ use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
+use OCP\Notification\UnknownNotificationException;
/**
* Class Notifier
@@ -78,12 +79,12 @@ class Notifier implements INotifier {
* @param INotification $notification
* @param string $languageCode The code of the language that should be used to prepare the notification
* @return INotification
- * @throws \Exception
+ * @throws UnknownNotificationException
*/
public function prepare(INotification $notification,
string $languageCode):INotification {
if ($notification->getApp() !== Application::APP_ID) {
- throw new \InvalidArgumentException('Notification not from this app');
+ throw new UnknownNotificationException('Notification not from this app');
}
// Read the language from the notification
@@ -95,7 +96,7 @@ class Notifier implements INotifier {
return $this->prepareReminderNotification($notification);
default:
- throw new \InvalidArgumentException('Unknown subject');
+ throw new UnknownNotificationException('Unknown subject');
}
}
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php
index 6f319766d21..dcf11a1a6b8 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php
@@ -16,6 +16,7 @@ use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\INotification;
+use OCP\Notification\UnknownNotificationException;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -88,7 +89,7 @@ class NotifierTest extends TestCase {
public function testPrepareWrongApp(): void {
- $this->expectException(\InvalidArgumentException::class);
+ $this->expectException(UnknownNotificationException::class);
$this->expectExceptionMessage('Notification not from this app');
/** @var INotification|MockObject $notification */
@@ -105,7 +106,7 @@ class NotifierTest extends TestCase {
public function testPrepareWrongSubject(): void {
- $this->expectException(\InvalidArgumentException::class);
+ $this->expectException(UnknownNotificationException::class);
$this->expectExceptionMessage('Unknown subject');
/** @var INotification|MockObject $notification */