Skip to content

Commit

Permalink
Improve handling when djdt views dont respond with JSON (#1877)
Browse files Browse the repository at this point in the history
  • Loading branch information
elineda committed Feb 22, 2024
1 parent e80c05d commit 9f66bd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion debug_toolbar/static/debug_toolbar/js/utils.js
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions docs/changes.rst
Expand Up @@ -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)
------------------
Expand Down

0 comments on commit 9f66bd3

Please sign in to comment.