mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Display API error information if available
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user