I have the following code to do a postback to a remote URL:
request = urllib2.Request(\'http://www.example.com\', postBackData, { \'User-Agent\' : \'My User
You can catch all exceptions and log what's get caught:
import sys
import traceback
def formatExceptionInfo(maxTBlevel=5):
cla, exc, trbk = sys.exc_info()
excName = cla.__name__
try:
excArgs = exc.__dict__["args"]
except KeyError:
excArgs = ""
excTb = traceback.format_tb(trbk, maxTBlevel)
return (excName, excArgs, excTb)
try:
x = x + 1
except:
print formatExceptionInfo()
(Code from http://www.linuxjournal.com/article/5821)
Also read documentation on sys.exc_info.