mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Catch non ok response codes and set the status to error and log the error. (#5236)
Co-authored-by: John Bolliger <john.bolliger@mx.com>
This commit is contained in:
parent
10598b5206
commit
70da442444
1 changed files with 17 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue