From 071d9145caff7dc884085fb0fdb0bca75b0a8d43 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 13 Jul 2021 15:02:07 +0200 Subject: [PATCH] js: don't attempt to log unexistent statusText --- app/javascript/shared/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/javascript/shared/utils.js b/app/javascript/shared/utils.js index ea0fd01f1..87568e452 100644 --- a/app/javascript/shared/utils.js +++ b/app/javascript/shared/utils.js @@ -57,7 +57,10 @@ export function ajax(options) { resolve({ 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 }); reject(error); }