Add custom 404 and 500 error handlers with corresponding templates
All checks were successful
Ruff / ruff (push) Successful in 10s
All checks were successful
Ruff / ruff (push) Successful in 10s
This commit is contained in:
@ -19,6 +19,36 @@ if TYPE_CHECKING:
|
||||
logger: logging.Logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def handler404(request: HttpRequest, exception: Exception | None = None) -> HttpResponse:
|
||||
"""Custom 404 error handler.
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The request object that caused the 404.
|
||||
exception (Exception, optional): The exception that caused the 404. Defaults to None.
|
||||
|
||||
Returns:
|
||||
HttpResponse: The rendered 404 template.
|
||||
"""
|
||||
logger.warning(
|
||||
"404 error occurred",
|
||||
extra={"path": request.path, "exception": str(exception) if exception else None},
|
||||
)
|
||||
return render(request=request, template_name="404.html", status=404)
|
||||
|
||||
|
||||
def handler500(request: HttpRequest) -> HttpResponse:
|
||||
"""Custom 500 error handler.
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The request object that caused the 500.
|
||||
|
||||
Returns:
|
||||
HttpResponse: The rendered 500 template.
|
||||
"""
|
||||
logger.error("500 error occurred", extra={"path": request.path})
|
||||
return render(request=request, template_name="500.html", status=500)
|
||||
|
||||
|
||||
@require_http_methods(request_method_list=["GET", "HEAD"])
|
||||
def get_home(request: HttpRequest) -> HttpResponse:
|
||||
"""Render the index page with drops grouped hierarchically by game and campaign.
|
||||
|
Reference in New Issue
Block a user