From ecb39fef9c12a1b80e35114948882c9ac97a7ed3 Mon Sep 17 00:00:00 2001 From: "Timo A. Hummel" Date: Sat, 28 Apr 2018 18:34:47 +0200 Subject: [PATCH] Fixed exception implementation for retrieving user preferences --- .../UserPreferenceNotFoundException.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/PartKeepr/AuthBundle/Exceptions/UserPreferenceNotFoundException.php b/src/PartKeepr/AuthBundle/Exceptions/UserPreferenceNotFoundException.php index e67bcce19..e91de7883 100644 --- a/src/PartKeepr/AuthBundle/Exceptions/UserPreferenceNotFoundException.php +++ b/src/PartKeepr/AuthBundle/Exceptions/UserPreferenceNotFoundException.php @@ -2,6 +2,7 @@ namespace PartKeepr\AuthBundle\Exceptions; +use PartKeepr\AuthBundle\Entity\User; use PartKeepr\CoreBundle\Exceptions\TranslatableException; /** @@ -9,8 +10,22 @@ */ class UserPreferenceNotFoundException extends TranslatableException { + private $user; + private $key; + + public function __construct(User $user, $key, $code = 0, \Throwable $previous = null) + { + $this->user = $user; + $this->key = $key; + + parent::__construct($code, $previous); + } + public function getMessageKey() { - return 'The requested user preference was not found'; + return sprintf('The requested user preference %s was not found for user %s', + $this->key, + $this->user->getUsername() + ); } }