--- a/error.py Mon Feb 16 02:49:06 2009 +0200
+++ b/error.py Mon Feb 16 02:55:17 2009 +0200
@@ -4,6 +4,17 @@
import traceback, sys, cgi, urllib
+def truncate (msg, limit) :
+ """
+ Truncate the given message to <limit> chars
+ """
+
+ if len(msg) > limit :
+ return msg[:limit-3] + '...'
+
+ else :
+ return msg
+
def build_error (exc_info=None, env=None) :
"""
Dumps out a raw traceback of the given/current exception to stdout.
@@ -51,7 +62,7 @@
version = None
# the exception type
- exception_str = traceback.format_exception_only(*exc_info[:2])[-1][:255]
+ exception_str = traceback.format_exception_only(*exc_info[:2])[-1]
# the exception traceback
traceback_lines = traceback.format_exception(*exc_info)
@@ -72,7 +83,7 @@
submit_args['revision'] = version
if exception_str :
- submit_args['summary'] = exception_str
+ submit_args['summary'] = truncate(exception_str, 140)
if traceback_lines :
# this is big
@@ -108,6 +119,6 @@
traceback = cgi.escape(''.join(traceback_lines)),
query_url = query_url,
submit_url = submit_url,
- submit_url_short = submit_url[:120] + '...'
+ submit_url_short = truncate(submit_url, 120)
)).encode('utf-8'))