mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Display API error information if available
This commit is contained in:
parent
1488a0e72f
commit
ae50546ca6
@ -225,6 +225,20 @@ function showApiError(xhr, url) {
|
|||||||
default:
|
default:
|
||||||
title = '{% trans "Unhandled Error Code" %}';
|
title = '{% trans "Unhandled Error Code" %}';
|
||||||
message = `{% trans "Error code" %}: ${xhr.status}`;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user