0
您好我有以下代码:工作了龙卷风例外
httpClient=AsyncHTTPClient()
try:
response=yield httpClient.fetch("http://ww.bbc.co.uk/news/uk-000")
except Exception as e:
print(e)
我特意取了一个无效的URL来解决如何处理错误。通过以上我得到:
[Errno 8] nodename nor servname provided, or not known
但是我试图找出什么异常类是这样的话,我做了以下内容:
httpClient=AsyncHTTPClient()
try:
response=yield httpClient.fetch("http://ww.bbc.co.uk/news/uk-000")
except Exception as e:
print(type(e))
我也得到:
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tornado-4.1-py3.4-macosx-10.6-intel.egg/tornado/gen.py", line 810, in run
yielded = self.gen.throw(*sys.exc_info())
File "messages.py", line 230, in on_message
print(type(e))
TypeError: 'str' object is not callable
首先我不明白为什么这个代码中的类型(e)不能告诉我这是什么类型的Exception类?
其次,龙卷风文档声明HTTPError被抛出,但它看起来并不像所有可以抛出的Exception。
感谢
本感谢。我现在感觉像是一个白痴......我正在使用一个叫做type:S的变量,并且为什么这样做不起作用而变得疯狂...... –