A
Anand Pillai
Hi
I am quite familiar with normal python errors which can
be caught by using the try... except... finally clause. But
very often I find other kinds of exceptions raised in my programs.
Here is an example.
<TRACEBACK>
Traceback (most recent call last):
File "D:\Python22\lib\threading.py", line 414, in __bootstrap
self.run()
File "WebUrlTracker.py", line 213, in run
self.action()
File "WebUrlTracker.py", line 207, in action
self.downloadUrl()
File "WebUrlTracker.py", line 249, in downloadUrl
self.fetchUrl()
File "WebUrlTracker.py", line 319, in fetchUrl
data=self._connection.fetchData(fetchurl)
File "WebUrlConnector.py", line 267, in fetchData
connection.request("GET", relpath)
File "D:\Python22\lib\httplib.py", line 702, in request
self._send_request(method, url, body, headers)
File "D:\Python22\lib\httplib.py", line 724, in _send_request
self.endheaders()
File "D:\Python22\lib\httplib.py", line 696, in endheaders
self._send_output()
File "D:\Python22\lib\httplib.py", line 582, in _send_output
self.send(msg)
File "D:\Python22\lib\httplib.py", line 549, in send
self.connect()
File "D:\Python22\lib\httplib.py", line 789, in connect
error: (10060, 'Operation timed out')
</TRACEBACK>
If I try to catch this using the try... except clause it does not work
(actually it raises another error for trying to catch 'error'), i.e the
following code fails.
try:
<Exception generating code>
except error, e:
print e
Could anyone tell me more about these errors and how to deal with
them ? Probably it is already documented in the python reference, but
I have missed it in that case.
Thanks
Anand Pillai
I am quite familiar with normal python errors which can
be caught by using the try... except... finally clause. But
very often I find other kinds of exceptions raised in my programs.
Here is an example.
<TRACEBACK>
Traceback (most recent call last):
File "D:\Python22\lib\threading.py", line 414, in __bootstrap
self.run()
File "WebUrlTracker.py", line 213, in run
self.action()
File "WebUrlTracker.py", line 207, in action
self.downloadUrl()
File "WebUrlTracker.py", line 249, in downloadUrl
self.fetchUrl()
File "WebUrlTracker.py", line 319, in fetchUrl
data=self._connection.fetchData(fetchurl)
File "WebUrlConnector.py", line 267, in fetchData
connection.request("GET", relpath)
File "D:\Python22\lib\httplib.py", line 702, in request
self._send_request(method, url, body, headers)
File "D:\Python22\lib\httplib.py", line 724, in _send_request
self.endheaders()
File "D:\Python22\lib\httplib.py", line 696, in endheaders
self._send_output()
File "D:\Python22\lib\httplib.py", line 582, in _send_output
self.send(msg)
File "D:\Python22\lib\httplib.py", line 549, in send
self.connect()
File "D:\Python22\lib\httplib.py", line 789, in connect
error: (10060, 'Operation timed out')
</TRACEBACK>
If I try to catch this using the try... except clause it does not work
(actually it raises another error for trying to catch 'error'), i.e the
following code fails.
try:
<Exception generating code>
except error, e:
print e
Could anyone tell me more about these errors and how to deal with
them ? Probably it is already documented in the python reference, but
I have missed it in that case.
Thanks
Anand Pillai