diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index 9189e4407..2e1f38d6b 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -23,6 +23,7 @@ * [#7101](https://github.com/netbox-community/netbox/issues/7101) - Enforce `MAX_PAGE_SIZE` for table and REST API pagination * [#7106](https://github.com/netbox-community/netbox/issues/7106) - Fix incorrect "Map It" button URL on a site's Physical Address field * [#7107](https://github.com/netbox-community/netbox/issues/7107) - Fix missing search button and search results in IP Address assignment "Assign IP" tab +* [#7109](https://github.com/netbox-community/netbox/issues/7109) - Ensure human readability of exceptions raised during REST API requests * [#7113](https://github.com/netbox-community/netbox/issues/7113) - Fix IPRange bulk options within Prefix view --- diff --git a/netbox/netbox/middleware.py b/netbox/netbox/middleware.py index ef50edc4a..e0f376223 100644 --- a/netbox/netbox/middleware.py +++ b/netbox/netbox/middleware.py @@ -113,6 +113,10 @@ class ExceptionHandlingMiddleware(object): def process_exception(self, request, exception): + # Handle exceptions that occur from REST API requests + if is_api_request(request): + return rest_api_server_error(request) + # Don't catch exceptions when in debug mode if settings.DEBUG: return @@ -121,10 +125,6 @@ class ExceptionHandlingMiddleware(object): if isinstance(exception, Http404): return - # Handle exceptions that occur from REST API requests - if is_api_request(request): - return rest_api_server_error(request) - # Determine the type of exception. If it's a common issue, return a custom error page with instructions. custom_template = None if isinstance(exception, ProgrammingError): diff --git a/netbox/templates/base/base.html b/netbox/templates/base/base.html index 13e11ebf2..ad2cefced 100644 --- a/netbox/templates/base/base.html +++ b/netbox/templates/base/base.html @@ -5,7 +5,7 @@