diff --git a/website/common/templates/500.html b/website/common/templates/500.html index 74beed6..416c4c7 100644 --- a/website/common/templates/500.html +++ b/website/common/templates/500.html @@ -4,9 +4,27 @@ Internal server error +

Internal server error

-

Sorry, there seems to be an error. Please try again soon.

+

You found a bug in my code - how dare you!

+

Return to safety →

diff --git a/website/common/tests/test_views.py b/website/common/tests/test_views.py index 847b07c..82fdde0 100644 --- a/website/common/tests/test_views.py +++ b/website/common/tests/test_views.py @@ -26,6 +26,16 @@ class Error404PageTestCase(TestCase): self.client.get(self.url) +class Error500PageTestCase(SimpleTestCase): + url = reverse("500") + + def test_accessible(self) -> None: + response = self.client.get(self.url) + self.assertContains( + response, "

Internal server error

", html=True, status_code=500 + ) + + class RobotsViewTestCase(SimpleTestCase): url = reverse("robotstxt") diff --git a/website/urls.py b/website/urls.py index faccb1e..a22777a 100644 --- a/website/urls.py +++ b/website/urls.py @@ -3,6 +3,7 @@ import re from django.conf import settings from django.urls import include, path, re_path from django.views.decorators.cache import cache_control, cache_page +from django.views.defaults import server_error from django.views.static import serve from wagtail import urls as wagtail_urls from wagtail.admin import urls as wagtailadmin_urls @@ -40,6 +41,7 @@ urlpatterns = [ name="keybase", ), path("404/", page_not_found, name="404"), + path("500/", server_error, name="500"), path("feed/", AllPagesFeed(), name="feed"), path(".health/", include("health_check.urls")), path("", include("website.legacy.urls")),