Skip to content

Commit

Permalink
Fixed exception implementation for retrieving user preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo A. Hummel committed Apr 28, 2018
1 parent d3ecfc6 commit ecb39fe
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@

namespace PartKeepr\AuthBundle\Exceptions;

use PartKeepr\AuthBundle\Entity\User;
use PartKeepr\CoreBundle\Exceptions\TranslatableException;

/**
* Is thrown when the user preference couldn't be found.
*/
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()
);
}
}

0 comments on commit ecb39fe

Please sign in to comment.