diff --git a/web/assets/javascripts/application.js b/web/assets/javascripts/application.js index 682d3bdf..25bd6e65 100644 --- a/web/assets/javascripts/application.js +++ b/web/assets/javascripts/application.js @@ -91,7 +91,19 @@ function updateLivePollButton() { function livePollCallback() { clearTimeout(livePollTimer); - fetch(window.location.href).then(resp => resp.text()).then(replacePage).finally(scheduleLivePoll) + fetch(window.location.href) + .then(checkResponse) + .then(resp => resp.text()) + .then(replacePage) + .catch(showError) + .finally(scheduleLivePoll) +} + +function checkResponse(resp) { + if (!resp.ok) { + throw response.error(); + } + return resp } function scheduleLivePoll() { @@ -111,3 +123,7 @@ function replacePage(text) { addListeners(); } + +function showError(error) { + console.error(error) +}