From ae50546ca67ea40872fe213ed88befdce2b63256 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 May 2022 00:25:32 +1000 Subject: [PATCH] Display API error information if available --- InvenTree/templates/js/translated/api.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/InvenTree/templates/js/translated/api.js b/InvenTree/templates/js/translated/api.js index 119376c310..5ec63ba51c 100644 --- a/InvenTree/templates/js/translated/api.js +++ b/InvenTree/templates/js/translated/api.js @@ -225,6 +225,20 @@ function showApiError(xhr, url) { default: title = '{% trans "Unhandled Error Code" %}'; message = `{% trans "Error code" %}: ${xhr.status}`; + + var response = xhr.responseJSON; + + // The server may have provided some extra information about this error + if (response) { + if (response.error) { + title = response.error + } + + if (response.detail) { + message = response.detail; + } + } + break; }