Display API error information if available

This commit is contained in:
Oliver Walters 2022-05-17 00:25:32 +10:00
parent 1488a0e72f
commit ae50546ca6

View File

@ -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;
} }