python 异常处理 库_Python:捕获第三方库异常

我在使用boto3和Amazon SNS时遇到以下错误。我只想捕获InvalidParameterException,我怎么能这样做呢?在Traceback (most recent call last):

File "D:\Logger\Notification.py", line 279, in

Push.subscribe(token1, 'android')

File "D:\Logger\Notification.py", line 119, in subscribe

'Enabled': b'True'

File "C:\Python27\lib\site-packages\botocore\client.py", line 310, in _api_call

return self._make_api_call(operation_name, kwargs)

File "C:\Python27\lib\site-packages\botocore\client.py", line 599, in _make_api_call

raise error_class(parsed_response, operation_name)

botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameter) when calling the CreatePlatformEndpoint operation: Invalid parameter: Token Reason: Endpoint arn:aws:sns:us-west-2:252285631092:endpoint/GCM/Test/06c4448e-545b-312a-978f-98af5d5829e4 already exists with the same Token, but different attributes.

如果我试图捕捉InvalidParameterException,它会显示

^{pr2}$

我已导入botocore。现在如果我试图捕捉botorcore.errorfactory.InvalidParameterException,它就会显示出来。在AttributeError: 'module' object has no attribute 'InvalidParameterException'

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值