diff --git a/core/error_views.py b/core/error_views.py new file mode 100644 index 0000000..ce0604b --- /dev/null +++ b/core/error_views.py @@ -0,0 +1,38 @@ +from django.shortcuts import render +from django.http import HttpResponseNotFound, HttpResponseServerError, HttpResponseForbidden, HttpResponseBadRequest + + +def custom_404_view(request, exception): + """Custom 404 error page with agent theme""" + return HttpResponseNotFound( + render(request, '404.html', { + 'timestamp': '1.0' # Cache busting for CSS + }).content + ) + + +def custom_500_view(request): + """Custom 500 error page with agent theme""" + return HttpResponseServerError( + render(request, '500.html', { + 'timestamp': '1.0' # Cache busting for CSS + }).content + ) + + +def custom_403_view(request, exception): + """Custom 403 error page with agent theme""" + return HttpResponseForbidden( + render(request, '403.html', { + 'timestamp': '1.0' # Cache busting for CSS + }).content + ) + + +def custom_400_view(request, exception): + """Custom 400 error page with agent theme""" + return HttpResponseBadRequest( + render(request, '400.html', { + 'timestamp': '1.0' # Cache busting for CSS + }).content + ) \ No newline at end of file diff --git a/netcop_hub/urls.py b/netcop_hub/urls.py index 22b04ac..e789af5 100644 --- a/netcop_hub/urls.py +++ b/netcop_hub/urls.py @@ -47,3 +47,9 @@ if settings.DEBUG: ] + urlpatterns except ImportError: pass + +# Custom error handlers (work in production when DEBUG=False) +handler404 = 'core.error_views.custom_404_view' +handler500 = 'core.error_views.custom_500_view' +handler403 = 'core.error_views.custom_403_view' +handler400 = 'core.error_views.custom_400_view' diff --git a/templates/400.html b/templates/400.html new file mode 100644 index 0000000..79a58f8 --- /dev/null +++ b/templates/400.html @@ -0,0 +1,334 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %}Bad Request - Quantum Tasks AI{% endblock %} + +{% block extra_css %} + +{% endblock %} + +{% block content %} + +{% include "components/agent_header.html" with agent_title="Bad Request" agent_subtitle="Invalid request format detected" %} + + +{% include "components/quick_agents_panel.html" %} + + +
Error ID: {{ request.META.HTTP_X_REQUEST_ID|default:"N/A" }}
-Time:
+ + +