From 05c22c4901158bdca2c23242473aacd0b2cf6325 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Wed, 1 Aug 2012 09:29:31 -0400 Subject: [PATCH] Prettier error display * Log formatted traceback string instead of exc_info tuple itself * display as a list --- common/lib/xmodule/xmodule/errortracker.py | 13 +++++++------ lms/templates/courseware.html | 8 +++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/errortracker.py b/common/lib/xmodule/xmodule/errortracker.py index 09c04c061c..b8d42a6983 100644 --- a/common/lib/xmodule/xmodule/errortracker.py +++ b/common/lib/xmodule/xmodule/errortracker.py @@ -1,5 +1,6 @@ import logging import sys +import traceback from collections import namedtuple @@ -14,21 +15,21 @@ def in_exception_handler(): def make_error_tracker(): '''Return an ErrorLog (named tuple), with fields (tracker, errors), where - the logger appends a tuple (message, exc_info=None) - to the errors on every call. + the logger appends a tuple (message, exception_str) to the errors on every + call. exception_str is in the format returned by traceback.format_exception. - error_list is a simple list. If the caller messes with it, info + error_list is a simple list. If the caller modifies it, info will be lost. ''' errors = [] def error_tracker(msg): '''Log errors''' - exc_info = None + exc_str = '' if in_exception_handler(): - exc_info = sys.exc_info() + exc_str = ''.join(traceback.format_exception(*sys.exc_info())) - errors.append((msg, exc_info)) + errors.append((msg, exc_str)) return ErrorLog(error_tracker, errors) diff --git a/lms/templates/courseware.html b/lms/templates/courseware.html index 0955134694..a14f35d154 100644 --- a/lms/templates/courseware.html +++ b/lms/templates/courseware.html @@ -51,7 +51,13 @@ % if course_errors is not UNDEFINED:

Course errors

- ${course_errors} +
% endif