<commit_before>from django.shortcuts import render

from core.models import ErrorReport


class ErrorMiddleware():
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        response = self.get_response(request)
        return response

    @staticmethod
    def process_exception(request, exception):
        report = ErrorReport.create(exception)
        report.save()
        return render(request, 'core/error.html', {'report': report})<commit_msg>Log exception traceback on error page<commit_after>from django.shortcuts import render

from core.models import ErrorReport

import logging
import traceback

LOGGER = logging.getLogger(__name__)

class ErrorMiddleware():
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        response = self.get_response(request)
        return response

    @staticmethod
    def process_exception(request, exception):
        LOGGER.debug(traceback.print_exc())
        report = ErrorReport.create(exception)
        report.save()
        return render(request, 'core/error.html', {'report': report})
{'fraction_non_alphanumeric': 0.08919382504288165, 'fraction_numerical': 0.0, 'mean_word_length': 3.630952380952381, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5472415', 'n_tokens_mistral': 310, 'n_tokens_neox': 306, 'n_words': 79}