mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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…
Reference in New Issue
Block a user