ministryofjustice / find-moj-data

Find MOJ data service • This repository is defined and managed in Terraform
MIT License
5 stars 0 forks source link

Error screens for no connection to datahub - datahub is not responding #210

Closed murdo-moj closed 3 months ago

murdo-moj commented 6 months ago
MatMoore commented 4 months ago

How to customise the error view: https://docs.djangoproject.com/en/5.0/topics/http/views/#customizing-error-views

Examples: https://ron.sh/handling-custom-django-error-pages-the-proper-way/

MatMoore commented 4 months ago

Overriding the 500 handler won't work as we can't access the original exception there:

    # All handlers take (request, exception) arguments except handler500
    # which takes (request).

Django handles this here https://github.com/django/django/blob/94ab56ee2e24d4764296580da66dbbdc9ba03b02/django/core/handlers/exception.py#L140 https://github.com/django/django/blob/94ab56ee2e24d4764296580da66dbbdc9ba03b02/django/urls/resolvers.py#L731

So looks like we need to implement this as a middleware https://docs.djangoproject.com/en/5.0/topics/http/middleware/#process-exception