From 25a4cdfafcea6bbbc5a596edab1599adbc3149fb Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 7 Apr 2022 01:16:17 +0800 Subject: [PATCH] handle tracker check user exception --- app/Repositories/TrackerRepository.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Repositories/TrackerRepository.php b/app/Repositories/TrackerRepository.php index 0d416db2..7a1dab07 100644 --- a/app/Repositories/TrackerRepository.php +++ b/app/Repositories/TrackerRepository.php @@ -298,7 +298,11 @@ class TrackerRepository extends BaseRepository if (!$user) { throw new TrackerException("Invalid user $field: $value."); } - $user->checkIsNormal(); + try { + $user->checkIsNormal(); + } catch (\Throwable $exception) { + throw new TrackerException($exception->getMessage()); + } if ($user->parked == 'yes') { throw new TrackerException("Your account is parked! (Read the FAQ)"); @@ -829,8 +833,8 @@ class TrackerRepository extends BaseRepository throw new TrackerException("key: info_hash is Missing !"); } else { foreach ($info_hash_array as $item) { - if (strlen($item) != 20) { - throw new TrackerException("Invalid info_hash ! info_hash is not 20 bytes long"); + if (($length = strlen($item)) != 20) { + throw new TrackerException("Invalid info_hash ! info_hash is not 20 bytes long($length)"); } } }