mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
add try/except
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from boto3 import client
|
from boto3 import client
|
||||||
|
from botocore.exceptions import ClientError
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from app.clients import AWS_CLIENT_CONFIG, Client
|
from app.clients import AWS_CLIENT_CONFIG, Client
|
||||||
@@ -25,13 +26,19 @@ class AwsPinpointClient(Client):
|
|||||||
return "pinpoint"
|
return "pinpoint"
|
||||||
|
|
||||||
def validate_phone_number(self, country_code, phone_number):
|
def validate_phone_number(self, country_code, phone_number):
|
||||||
|
try:
|
||||||
response = self._client.phone_number_validate(
|
response = self._client.phone_number_validate(
|
||||||
NumberValidateRequest={"IsoCountryCode": country_code, "PhoneNumber": phone_number}
|
NumberValidateRequest={
|
||||||
|
"IsoCountryCode": country_code,
|
||||||
|
"PhoneNumber": phone_number,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO right now this will only print with AWS simulated numbers,
|
# TODO right now this will only print with AWS simulated numbers,
|
||||||
# but remove this when that changes
|
# but remove this when that changes
|
||||||
current_app.logger.info(hilite(response))
|
current_app.logger.info(hilite(response))
|
||||||
|
except ClientError:
|
||||||
|
current_app.logger.exception("Could not validate with pinpoint")
|
||||||
|
|
||||||
# TODO This is the structure of the response. When the phone validation
|
# TODO This is the structure of the response. When the phone validation
|
||||||
# capability we want to offer is better defined (it may just be a question
|
# capability we want to offer is better defined (it may just be a question
|
||||||
|
|||||||
Reference in New Issue
Block a user