diff --git a/breakpad.py b/breakpad.py index f8f1a1b5a..21b13f801 100644 --- a/breakpad.py +++ b/breakpad.py @@ -27,6 +27,34 @@ DEFAULT_URL = 'https://chromium-status.appspot.com/breakpad' _REGISTERED = False +def FormatException(e): + """Returns a human readable form of an exception. + + Adds the maximum number of interesting information in the safest way.""" + try: + out = repr(e) + except Exception: + out = '' + try: + out = str(e) + if isinstance(e, Exception): + # urllib exceptions, usually the HTTP headers. + if hasattr(e, 'headers'): + out += '\nHeaders: %s' % e.headers + if hasattr(e, 'url'): + out += '\nUrl: %s' % e.url + if hasattr(e, 'msg'): + out += '\nMsg: %s' % e.msg + # The web page in some urllib exceptions. + if hasattr(e, 'read') and callable(e.read): + out += '\nread(): %s' % e.read() + if hasattr(e, 'info') and callable(e.info): + out += '\ninfo(): %s' % e.info() + except Exception: + pass + return out + + def SendStack(last_tb, stack, url=None): """Sends the stack trace to the breakpad server.""" if not url: @@ -35,19 +63,13 @@ def SendStack(last_tb, stack, url=None): try: params = { 'args': sys.argv, - 'stack': stack, + 'stack': stack[0:4096], 'user': getpass.getuser(), - 'exception': last_tb, + 'exception': FormatException(last_tb), 'host': socket.getfqdn(), 'cwd': os.getcwd(), } - # No exception type(s) specified # pylint: disable=W0702 - try: - # That may not always work. - params['exception'] = str(last_tb) - except: - pass print('\n'.join(' %s: %s' % (k, v[0:50]) for k, v in params.iteritems())) request = urllib.urlopen(url, urllib.urlencode(params)) print(request.read()) diff --git a/gclient_utils.py b/gclient_utils.py index 5ab1ed509..718284852 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -701,8 +701,6 @@ class ExecutionQueue(object): """Runs in its own thread.""" logging.debug('running(%s)' % self.item.name) work_queue = self.kwargs['work_queue'] - # It's necessary to catch all exceptions. - # pylint: disable=W0703 try: self.item.run(*self.args, **self.kwargs) except Exception: diff --git a/pylintrc b/pylintrc index 92da7be07..371ff4319 100644 --- a/pylintrc +++ b/pylintrc @@ -56,8 +56,9 @@ load-plugins= # W0511: TODO # W0603: Using the global statement # W0613: Unused argument '' +# W0703: Catch "Exception" # W6501: Specify string format arguments as logging function parameters -disable=C0103,C0111,C0302,I0011,R0401,R0801,R0901,R0902,R0903,R0911,R0912,R0913,R0914,R0915,W0122,W0141,W0142,W0402,W0511,W0603,W0613,W6501 +disable=C0103,C0111,C0302,I0011,R0401,R0801,R0901,R0902,R0903,R0911,R0912,R0913,R0914,R0915,W0122,W0141,W0142,W0402,W0511,W0603,W0613,W0703,W6501 [REPORTS]