From 49300900d6828ce1bb2ad3e931634e76be528606 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 13 Aug 2023 13:47:37 +0200 Subject: [PATCH] News: Catch all throwable exceptions --- src/Events/Listener/News.php | 4 ++-- tests/Unit/Events/Listener/NewsTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Events/Listener/News.php b/src/Events/Listener/News.php index f609ca01..052a126a 100644 --- a/src/Events/Listener/News.php +++ b/src/Events/Listener/News.php @@ -8,9 +8,9 @@ use Engelsystem\Mail\EngelsystemMailer; use Engelsystem\Models\News as NewsModel; use Engelsystem\Models\User\Settings as UserSettings; use Engelsystem\Models\User\User; -use Exception; use Illuminate\Database\Eloquent\Collection; use Psr\Log\LoggerInterface; +use Throwable; class News { @@ -43,7 +43,7 @@ class News $template, ['title' => $news->title, 'news' => $news, 'username' => $user->displayName] ); - } catch (Exception $e) { + } catch (Throwable $e) { $this->log->error( 'Unable to send email "{title}" to user {user} with {exception}', ['title' => $subject, 'user' => $user->name, 'exception' => $e] diff --git a/tests/Unit/Events/Listener/NewsTest.php b/tests/Unit/Events/Listener/NewsTest.php index 80664fa9..050570c6 100644 --- a/tests/Unit/Events/Listener/NewsTest.php +++ b/tests/Unit/Events/Listener/NewsTest.php @@ -12,10 +12,10 @@ use Engelsystem\Models\User\Settings; use Engelsystem\Models\User\User; use Engelsystem\Test\Unit\HasDatabase; use Engelsystem\Test\Unit\TestCase; +use Exception; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Psr\Log\Test\TestLogger; -use Symfony\Component\Mailer\Exception\TransportException; class NewsTest extends TestCase { @@ -48,7 +48,7 @@ class NewsTest extends TestCase $this->assertEquals('Foo', array_values($data)[0]); if ($i++ > 0) { // On second run - throw new TransportException('Oops'); + throw new Exception('Oops'); } });