【发布时间】:2021-07-26 03:11:45
【问题描述】:
我正在使用AWS Cognito 制作OAuth 服务器。我现在正在创建异常处理程序以防万一使用不存在,但 requests 打算得到一个
ipdb> pk
'David'
ipdb> res = self.cognito_client.admin_get_user(
UserPoolId=settings.AWS_USER_POOL_ID,
Username=pk
)
*** botocore.errorfactory.UserNotFoundException: An error occurred (UserNotFoundException) when calling the AdminGetUser operation: User does not exist.
Traceback (most recent call last):
File "/Users/sarit/.pyenv/versions/futuready-titan/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Users/sarit/.pyenv/versions/futuready-titan/lib/python3.8/site-packages/botocore/client.py", line 626, in _make_api_call
raise error_class(parsed_response, operation_name)
boto3==1.12.15 # via -r el.in
botocore==1.15.15 # via boto3, s3transfer
django==3.0.3
python3.8.1
我已经与botocore source codeUserNotFoundException核实过
问题:
我怎么能具体catch这个exception?
【问题讨论】:
-
你是刚刚创建了一个用户,还是老了?通常,激活亚马逊帐户需要大约 1 天时间。
-
你
try已经做什么了? (双关语:p) -
@wovano 我试过
BotoCoreError,但它不起作用