diff --git a/js/src/data/actions.js b/js/src/data/actions.js index 64dfd5fd10..553627298c 100644 --- a/js/src/data/actions.js +++ b/js/src/data/actions.js @@ -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,