Skip to content

Commit 39a54d8

Browse files
author
Your Name
committed
fix exception message handling
1 parent 4ab69be commit 39a54d8

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 5.0.0 - 2025-01-26
22
- Add support otp lifetime token functionality with expiration handling
3+
- Replace `InvalidOTPTokenException` and `UserNotFoundByMobileException` with `OTPException` for better error handling
34

45
## 4.3.0 - 2024-06-21
56
- Add support only confirm token

lang/en/otp.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@
1313
'otp_token' => 'Your OTP Token is: :token.',
1414

1515
'otp_subject' => 'OTP request',
16+
17+
'token_has_been_expired_or_invalid' => 'the token has been expired or invalid',
18+
19+
'user_not_found_by_mobile' => 'user not found by mobile',
20+
21+
'otp_has_already_been_sent_for_this_mobile' => 'OTP has already been sent for this mobile',
1622
];

src/Exceptions/OTPException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ class OTPException extends Exception
88
{
99
public static function whenOtpTokenIsInvalid(): static
1010
{
11-
return new static('The token has been expired or invalid.');
11+
return new static('token_has_been_expired_or_invalid');
1212
}
1313

1414
public static function whenUserNotFoundByMobile(): static
1515
{
16-
return new static('User not found by mobile.');
16+
return new static('user_not_found_by_mobile');
1717
}
1818

1919
public static function whenOtpAlreadySent(): static
2020
{
21-
return new static('OTP has already been sent for this mobile.');
21+
return new static('otp_has_already_been_sent_for_this_mobile');
2222
}
2323
}

0 commit comments

Comments
 (0)