【发布时间】:2012-10-30 09:31:37
【问题描述】:
我用 urlfetch 测试人们提供的 URL 以捕获错误的链接。
result = urlfetch.fetch(url)
当我提供诸如 «http://qwerty.uiop» 之类的 URL 时,日志显示存在 «DNSLookupFailedError»,但这段代码无法捕捉到它:
except urlfetch.DNSLookupFailedError:
self.error(400)
self.response.out.write(
'Sorry, there was a problem with URL "' + url + '"')
我也试过“除了 urlfetch.Error:”和“除了 urlfetch.DownloadError:”
我做错了什么,还有其他方法可以完成我想做的事情吗?
【问题讨论】:
标签: python google-app-engine error-handling dns urlfetch