Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django.conf import settings
4from django.urls import reverse, NoReverseMatch
5import logging
6from superdjango.shortcuts import get_model
7from .base import ErrorHandler
9log = logging.getLogger(__name__)
11# Exports
13__all__ = (
14 "Model",
15)
17# Classes
20class Model(ErrorHandler):
21 """Write errors to the database."""
23 required_settings = [
24 "SUPERDJANGO_ERROR_CAPTURE_MODEL_NAME",
25 ]
27 # def handle(self, request, exception, traceback):
28 def handle(self, report):
29 """Create an error record."""
30 model = get_model(settings.SUPERDJANGO_ERROR_CAPTURE_MODEL_NAME, raise_exception=False)
31 if model is None:
32 log.error("Error capture model does not exist: %s" % settings.SUPERDJANGO_ERROR_CAPTURE_MODEL_NAME)
33 return None
35 instance = model.log(report)
36 try:
37 url = reverse("captured_error_detail", kwargs={'uuid': instance.identifier})
38 return {'issue_url': url}
39 except NoReverseMatch:
40 return None