Skip to content

Commit 1b11cb9

Browse files
authored
Improve exception thrown when user does not exists
User not found is not a RuntimeException. It must be a NotFoundException
1 parent c5a1e9b commit 1b11cb9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/User/Service/PasswordRecoveryService.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Da\User\Traits\ModuleAwareTrait;
2020
use Exception;
2121
use Yii;
22+
use yii\web\NotFoundHttpException;
2223

2324
class PasswordRecoveryService implements ServiceInterface
2425
{
@@ -50,7 +51,7 @@ public function run()
5051
$user = $this->query->whereEmail($this->email)->one();
5152

5253
if ($user === null) {
53-
throw new \RuntimeException('User not found.');
54+
throw new NotFoundHttpException(Yii::t('usuario', 'User not found'));
5455
}
5556

5657
$token = TokenFactory::makeRecoveryToken($user->id);

0 commit comments

Comments
 (0)