Handle parse exception
This commit is contained in:
parent
edac2e334f
commit
b6faf425fd
1 changed files with 6 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ from urllib.parse import urlparse
|
|||
|
||||
import phonenumbers
|
||||
from django.apps import apps
|
||||
from phonenumbers import NumberParseException
|
||||
from python_http_client import UnauthorizedError
|
||||
from sendgrid import SendGridAPIClient
|
||||
from telegram import Bot
|
||||
|
|
@ -126,8 +127,11 @@ class LiveSettingValidator:
|
|||
|
||||
@staticmethod
|
||||
def _is_phone_number_valid(phone_number):
|
||||
ph_num = phonenumbers.parse(phone_number)
|
||||
return phonenumbers.is_valid_number(ph_num)
|
||||
try:
|
||||
ph_num = phonenumbers.parse(phone_number)
|
||||
return phonenumbers.is_valid_number(ph_num)
|
||||
except NumberParseException:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _prettify_twilio_error(exc):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue