js: don't attempt to log unexistent statusText

This commit is contained in:
Pierre de La Morinerie 2021-07-13 15:02:07 +02:00
parent 99b836da2c
commit 071d9145ca

View file

@ -57,7 +57,10 @@ export function ajax(options) {
resolve({ response, statusText, xhr }); resolve({ response, statusText, xhr });
}, },
error: (response, statusText, xhr) => { error: (response, statusText, xhr) => {
let error = new Error(`Erreur ${xhr.status} : ${statusText}`); // NB: on HTTP/2 connections, statusText is always empty.
let error = new Error(
`Erreur ${xhr.status}` + (statusText ? ` : ${statusText}` : '')
);
Object.assign(error, { response, statusText, xhr }); Object.assign(error, { response, statusText, xhr });
reject(error); reject(error);
} }