What errors/exceptions do I need to handle with urllib2.Request / urlopen?

Add generic exception handler:

request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })

try: 
    response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
    checksLogger.error('HTTPError=" + str(e.code))
except urllib2.URLError, e:
    checksLogger.error("URLError=" + str(e.reason))
except httplib.HTTPException, e:
    checksLogger.error("HTTPException')
except Exception:
    import traceback
    checksLogger.error('generic exception: ' + traceback.format_exc())

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)