python 异常处理except_Python请求异常处理Bad except子句顺序 (Python requests exception handling Bad except clauses ...

2015-11-18 19:53:47

0

I'm writing a fault tolerant HTTP client with the requests library and I want to handle all the exceptions that are defined in requests.exceptions

Here are the exception that are defined within requests.exceptions:

'''

exceptions.BaseHTTPError exceptions.HTTPError exceptions.ProxyError exceptions.TooManyRedirects

exceptions.ChunkedEncodingError exceptions.InvalidSchema exceptions.RequestException exceptions.URLRequired

exceptions.ConnectionError exceptions.InvalidURL exceptions.SSLError

exceptions.ContentDecodingError exceptions.MissingSchema exceptions.Timeout

'''

When I use pylint on my application, I'm getting an error message as described in http://pylint-messages.wikidot.com/messages:e0701 which indicates that the order is not correct. What is the proper order I should be catching the errors in (so as to not mask a more specific error by catching the generic one first), and is there a general purpose way to determine this?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值