Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Unified Diff: breakpad.py

Issue 5303002: Add more exception information to breakpad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: remove upload.py added by error, limit stack length to 4096 Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: breakpad.py
diff --git a/breakpad.py b/breakpad.py
index f8f1a1b5aa77f95b43ef74359a157c0a9396ad4f..21b13f801ba6472a0f85d77e27e4b90bb846987d 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())
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698