'Handle exceptions raised when rendering a view.'

@staticmethod
def handle_exceptions(request, course, exception):

    if (isinstance(exception, Redirect) or isinstance(exception, Http404)):
        raise
    if isinstance(exception, UnicodeEncodeError):
        raise Http404('URL    contains    Unicode    characters')
    if settings.DEBUG:
        raise
    user = request.user
    log.exception(u'Error    in    %s:    user=%s,    effective_user=%s,    course=%s', request.path, getattr(user, 'real_user', user), user, unicode(course.id))
    try:
        return render_to_response('courseware/courseware-error.html', {'staff_access': has_access(user, 'staff', course), 'course': course}, status=500)
    except:
        log.exception('Error    while    rendering    courseware-error    page')
        raise
