Changeset 2927 in products


Ignore:
Timestamp:
Oct 26, 2010 2:33:27 PM (14 years ago)
Author:
mylan
Message:

#233: Reduce catch exceptions to URLError and HTTPError, log error to error_log, return link to error_log

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/keywords.py

    r2901 r2927  
    1 import re, commands, urllib2 
     1import re, sys, urllib2 
    22from xml.dom import Node 
    33 
     
    3535                                 context=self.context) 
    3636        # Get html page internally or with external request 
     37        error_url = "" 
    3738        if isExternal: 
    3839            # Not pass timeout option because: 
     
    4546                finally: 
    4647                    'resp' in locals().keys() and resp.close() 
    47             except Exception: 
     48            except (urllib2.URLError, urllib2.HTTPError), e: 
    4849                # In case of exceed timeout period or other URL connection errors. 
     50                info = sys.exc_info() 
     51                elog = getToolByName(self.context, "error_log") 
     52                if elog: 
     53                    error_url = elog.raising(info) 
    4954                html = None 
    5055        else: 
     
    6065                result.append(' - '.join((keyword, keyword_on_page))) 
    6166        else: 
    62             result.append("Problem with page retrieval") 
     67            sfx = error_url and ", details at %s." % error_url or "." 
     68            result.append("Problem with page retrieval" + sfx) 
    6369 
    6470        return ts.utranslate(domain='quintagroup.seoptimizer', 
Note: See TracChangeset for help on using the changeset viewer.