diff --git a/debug_toolbar/static/debug_toolbar/js/utils.js b/debug_toolbar/static/debug_toolbar/js/utils.js index b4c7a4cb8..c37525f13 100644 --- a/debug_toolbar/static/debug_toolbar/js/utils.js +++ b/debug_toolbar/static/debug_toolbar/js/utils.js @@ -75,7 +75,11 @@ function ajax(url, init) { return fetch(url, init) .then(function (response) { if (response.ok) { - return response.json(); + return response.json().catch(function(error){ + return Promise.reject( + new Error("The response is a invalid Json object : " + error) + ); + }); } return Promise.reject( new Error(response.status + ": " + response.statusText) diff --git a/docs/changes.rst b/docs/changes.rst index a3bf6a934..3ffa31dea 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -7,6 +7,8 @@ Pending * Raised the minimum Django version to 4.2. * Automatically support Docker rather than having the developer write a workaround for ``INTERNAL_IPS``. +* Display a better error message when the toolbar's requests + return invalid json. 4.3.0 (2024-02-01) ------------------