sentry: integration with error 500 page

This commit is contained in:
Antoine Bartuccio 2018-10-10 02:07:13 +02:00
parent f7be284b30
commit bdd8427758
Signed by: klmp200
GPG Key ID: E7245548C53F904B
4 changed files with 654 additions and 621 deletions

View File

@ -0,0 +1,15 @@
{% extends "core/base.jinja" %}
{% block head %}
{{ super() }}
<script src="https://browser.sentry-cdn.com/4.0.6/bundle.min.js" crossorigin="anonymous"></script>
{% endblock head %}
{% block content %}
<h3>{% trans %}500, Server Error{% endtrans %}</h3>
{% if request.sentry_dsn %}
<script>
Sentry.init({ dsn: '{{ request.sentry_dsn }}' });
Sentry.showReportDialog({ eventId: '{{ request.sentry_last_event_id() }}' })
</script>
{% endif %}
{% endblock content %}

View File

@ -24,8 +24,14 @@
import types import types
from sentry_sdk import last_event_id
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponseForbidden, HttpResponseNotFound from django.http import (
HttpResponseForbidden,
HttpResponseNotFound,
HttpResponseServerError,
)
from django.template import RequestContext
from django.core.exceptions import ( from django.core.exceptions import (
PermissionDenied, PermissionDenied,
ObjectDoesNotExist, ObjectDoesNotExist,
@ -65,6 +71,12 @@ def not_found(request):
return HttpResponseNotFound(render(request, "core/404.jinja")) return HttpResponseNotFound(render(request, "core/404.jinja"))
def internal_servor_error(request):
request.sentry_dsn = settings.SENTRY_DSN
request.sentry_last_event_id = last_event_id
return HttpResponseServerError(render(request, "core/500.jinja"))
def can_edit_prop(obj, user): def can_edit_prop(obj, user):
if obj is None or user.is_owner(obj): if obj is None or user.is_owner(obj):
return True return True

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,7 @@ js_info_dict = {"packages": ("sith",)}
handler403 = "core.views.forbidden" handler403 = "core.views.forbidden"
handler404 = "core.views.not_found" handler404 = "core.views.not_found"
handler500 = "core.views.internal_servor_error"
urlpatterns = [ urlpatterns = [
url(r"^", include("core.urls", namespace="core", app_name="core")), url(r"^", include("core.urls", namespace="core", app_name="core")),