Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a custom 500 page #867

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions alyx/alyx/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import traceback
from django.conf.urls import include
from django.urls import path
from django.contrib import admin
from django.shortcuts import render
from rest_framework.authtoken import views as authv
from rest_framework.documentation import include_docs_urls

Expand All @@ -25,3 +27,11 @@
urlpatterns += [path('ibl_reports/', include('ibl_reports.urls')), ]
except ModuleNotFoundError:
pass


def handler500(request):
ctx = {
'request': request.path,
'traceback': traceback.format_exc()
}
return render(request, 'error_500.html', ctx)
76 changes: 76 additions & 0 deletions alyx/templates/error_500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>500 Internal Server Error</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
color: #343a40;
margin: 0;
padding: 0;
}
.container {
max-width: 1200px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #dc3545;
font-size: 2em;
margin-bottom: 0.5em;
}
p {
font-size: 1.2em;
margin-bottom: 1em;
}
.request {
background-color: #d4edda; /* Light green background */
color: #155724; /* Dark green text color */
border: 1px solid #c3e6cb; /* Green border */
border-radius: 5px;
padding: 15px;
overflow-x: auto;
white-space: pre-wrap;
font-family: Consolas, "Courier New", monospace;
font-size: 1.0em;
}
.traceback {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
border-radius: 5px;
padding: 15px;
overflow-x: auto;
white-space: pre-wrap;
font-family: Consolas, "Courier New", monospace;
font-size: 0.8em; /* Smaller font size for the traceback */
}

.footer {
margin-top: 20px;
text-align: center;
font-size: 0.7em;
color: #6c757d;
}
</style>
</head>
<body>
<div class="container">
<h1>500 Internal Server Error</h1>
<p>Oupsy, something went wrong on our end. !</p>
<p>Feel free to reach out with the information below, we'll do our best to resolve the issue.</p>
<div class="request">
{{ request|safe }}
</div>
<div class="traceback">
{{ traceback|safe }}
</div>
</div>
</body>
</html>
Loading