Skip to content

Commit

Permalink
Merge pull request #1999 from woocommerce/fix/1101-invalid-phone-numb…
Browse files Browse the repository at this point in the history
…er-error-msg

Show a general error message when the phone number verification request is failed
  • Loading branch information
eason9487 authored Jun 26, 2023
2 parents 1eef8a1 + cbda283 commit 3cc6936
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/src/data/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,22 @@ export function* requestPhoneVerificationCode( country, phoneNumber, method ) {
verificationId: response.verification_id,
};
} catch ( error ) {
// Currently, 'badRequest' won't be presented and all error responses return the
// same reason 'backendError'. Maybe someday the error reason can be distinguished
// and then we can recheck if there is a better way to handle errors.
//
// Ref:
// - https://github.com/woocommerce/google-listings-and-ads/issues/1101
// - https://github.com/woocommerce/google-listings-and-ads/issues/1998
if ( error.reason === 'backendError' ) {
throw {
display: __(
'Unable to request the verification code. This may be due to an invalid phone number or the limit of five attempts to verify the same phone number every four hours.',
'google-listings-and-ads'
),
};
}

if ( error.reason === 'rateLimitExceeded' ) {
throw {
...error,
Expand Down

0 comments on commit 3cc6936

Please sign in to comment.